Skip to content

Mosquitto Example Configuration

Marius Kießling edited this page Jul 25, 2020 · 1 revision

I am using Mosquitto with ACL enabled as my MQTT broker. This page shows excerpts of my configuration which can help you to set up your installation. This page is not intended to be used a guide to fully setup Mosquitto. Please consult the Mosquitto configuration man page for more information.

Main Configuration File

/etc/mosquitto/mosquitto.conf

I enable anonymous access which is required for some consumers to successfully interact with the broker. The main configuration file also references the password database file as well as the ACL configuration file.

[...]

password_file /etc/mosquitto/passwd
acl_file /etc/mosquitto/acl
allow_anonymous true

Password File

/etc/mosquitto/passwd

You can generate a password in the format expected by Mosquitto using

sudo mosquitto_passwd -c /etc/mosquitto/passwd my-user
⚠️

The target file is fully overwritten by each execution of the mosquitto_passwd file. If you plan to create more than one user, e.g. one for the ecovacs-mqtt set up and one for the consumer of the information published by it, you have to point the command to a different file. The content of this file can then simply be appended to the main password file of Mosquitto resulting in a file looking like this:

user1:$6$[...]==
user2:$6$[...]==

ACL File

/etc/mosquitto/acl

The first line without any prefixed user allows the anonymous user to read system information about the Mosquitto instance. The third and fourth line grant user1 r/w access to the deboot topic and all topics within it.

topic read $SYS/#

user user1
topic deboot/#
Clone this wiki locally