Mosquitto is an open source message broker that implements the MQTT protocol. It is lightweight and is suitable for use on all devices from low power single board computers to full servers.


sudo apt install mosquitto mosquitto-clients


Place a .conf file in /etc/mosquitto/conf.d

Setting up a listener

listener 1883
protocol mqtt

Also available for websockets:

listener 9001
protocol websockets

Setting up authentication

allow_anonymous false
password_file /etc/mosquitto/passwd

the file /etc/mosquitto/passwd can be created using an utility provided by mosquitto (run as root):

mosquitto_passwd -c /etc/mosquitto/passwd username