I’ve tried reading on the topic but all I’ve found is ambiguous information.
I’ve installed Mosquitto by clicking the automatic setup button on the HA docs.
And it seems it runs as the root user, because I don’t see any other user in the list of people and the warning Warning: Mosquitto should not be run as root/administrator
is displayed in the logs.
Should I leave it like this or should I create another user and make Mosquitto run under it?
Asking also because my Shelly sensor wants a username and password for MQTT (or at least it has a textbox for both, not sure if required).
If you go into the mosquitto add-on config, you can add logins there…
- username: "!secret MQTT_Bridge_Login"
password: "!secret MQTT_Bridge_Password"
- username: "!secret MQTT_Login"
password: "!secret MQTT_Password"
- username: "!secret MQTT_Z2M_User"
password: "!secret MQTT_Z2M_Password"
I use secrets because I’m on yout ube sometimes, but you don’t have to use secrets.
I’ve read that if Mosquitto does NOT run as root it won’t work because of Docker. Is this true and SHOULD I add a separate user?
There are 2 things you are asking about.
Mosquitto if it’s running, just let it run like that. I would not mess with the user that it owns.
That was my answer above.