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