Professional Documents
Culture Documents
com
Introduction
https://www.vultr.com/docs/install-mosquitto-mqtt-broker-on-ubuntu-20-04-server/ 1/10
7/19/22, 7:22 PM Install Mosquitto MQTT Broker On Ubuntu 20.04 Server - Vultr.com
Prerequisites
https://www.vultr.com/docs/install-mosquitto-mqtt-broker-on-ubuntu-20-04-server/ 2/10
7/19/22, 7:22 PM Install Mosquitto MQTT Broker On Ubuntu 20.04 Server - Vultr.com
Categories Linux$Guides
sudo apt install
Install -yMQTT
Mosquitto mosquitto
Br…
man:mosquitto(8)
...
https://www.vultr.com/docs/install-mosquitto-mqtt-broker-on-ubuntu-20-04-server/ 3/10
7/19/22, 7:22 PM Install Mosquitto MQTT Broker On Ubuntu 20.04 Server - Vultr.com
home/lights/sitting_room
home/lights/kitchen
home/lights/master_bedroom
home/lights/kids_bedroom
3. To subscribe to a topic, execute the mosquitto_sub -
t command followed by the name of the topic that you
want to subscribe to. For example, to subscribe to the
home/lights/sitting_room topic, execute.
$ mosquitto_sub -t "home/lights/sitting_ro
https://www.vultr.com/docs/install-mosquitto-mqtt-broker-on-ubuntu-20-04-server/ 4/10
7/19/22, 7:22 PM Install Mosquitto MQTT Broker On Ubuntu 20.04 Server - Vultr.com
Categories
$ mosquitto_pub
Linux Guides
-m "ON" -t "home/lights/si
Install Mosquitto MQTT Br…
ON
ON
OFF
https://www.vultr.com/docs/install-mosquitto-mqtt-broker-on-ubuntu-20-04-server/ 5/10
7/19/22, 7:22 PM Install Mosquitto MQTT Broker On Ubuntu 20.04 Server - Vultr.com
/etc/mosquitto/conf.d
https://www.vultr.com/docs/install-mosquitto-mqtt-broker-on-ubuntu-20-04-server/ 6/10
7/19/22, 7:22 PM Install Mosquitto MQTT Broker On Ubuntu 20.04 Server - Vultr.com
allow_anonymous false
password_file /etc/mosquitto/passwd
6. Then, populate the file with the account details for the
users that you want to connect to the Mosquitto server.
Replace EXAMPLE_PASSWORD and
EXAMPLE_PASSWORD_2 with strong values.
john_doe:EXAMPLE_PASSWORD
mary_smith:EXAMPLE_PASSWORD_2
Output.
john_doe:$6$TSzNycsj...5Qyvgd4g==
mary_smith:$6$DtlKf1lG.../rLHIL0Q==
https://www.vultr.com/docs/install-mosquitto-mqtt-broker-on-ubuntu-20-04-server/ 7/10
7/19/22, 7:22 PM Install Mosquitto MQTT Broker On Ubuntu 20.04 Server - Vultr.com
Categories
$ sudo systemctl
Linux Guides
restart mosquitto
11. From this point forward, you should execute any pub/sub
command using the syntax below. Remember to replace
john_doe and EXAMPLE_PASSWORD with the
credentials that you defined in the password file.
Output.
...
Conclusion
https://www.vultr.com/docs/install-mosquitto-mqtt-broker-on-ubuntu-20-04-server/ 8/10
7/19/22, 7:22 PM Install Mosquitto MQTT Broker On Ubuntu 20.04 Server - Vultr.com
Suggest an update
Request an article
Products
Features
Use Cases
Marketplace
Resources
Company
Terms of Service
AUP/DMCA
Privacy Policy
Cookie Policy
https://www.vultr.com/docs/install-mosquitto-mqtt-broker-on-ubuntu-20-04-server/ 9/10
7/19/22, 7:22 PM Install Mosquitto MQTT Broker On Ubuntu 20.04 Server - Vultr.com
https://www.vultr.com/docs/install-mosquitto-mqtt-broker-on-ubuntu-20-04-server/ 10/10