Install Mosquitto MQTT Messaging Broker on Ubuntu 16.04

sudo apt-get install mosquitto mosquitto-clients

Test

mosquitto_sub -h localhost -t test
mosquitto_pub -h localhost -t test -m "hello world"

Configuring MQTT Passwords

sudo mosquitto_passwd -c /etc/mosquitto/passwd sammy
sudo nano /etc/mosquitto/conf.d/default.conf
allow_anonymous false
password_file /etc/mosquitto/passwd
sudo systemctl restart mosquitto

References
https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-the-mosquitto-mqtt-messaging-broker-on-ubuntu-16-04