Installing Mosquitto: an MQTT broker for home automation

Published on 20/04/2026 IoT
The Firmware Factory
Advertisement
The Firmware Factory — custom firmware development for embedded devices
Learn more

Installation

sudo apt install mosquitto mosquitto-clients
sudo systemctl enable --now mosquitto

Creating a user

sudo mosquitto_passwd -c /etc/mosquitto/passwd mqtt_user

Type the password when prompted.

Configuration

Create /etc/mosquitto/conf.d/default.conf:

listener 1883
allow_anonymous false
password_file /etc/mosquitto/passwd

Restart it: sudo systemctl restart mosquitto.

Testing

mosquitto_sub -h localhost -u mqtt_user -P password -t test/#

In another shell: mosquitto_pub -h localhost -u mqtt_user -P password -t test/hello -m "Hello"