Hey everyone,
I am working in Chirpstack docker trying to set up my MQTT broker to use username/password authentication from the gateways. I have set up my mosquitto.conf listener to use the passwordfile and everything works fine.
My problem is when trying to add a username/password using mosquitto_passwd -b passwordfile user password
with or without sudo, I get the error: Error reading password file: Permission denied
My current file permissions are:
local@lorawan-ns:~/chirpstack-docker/configuration/mosquitto/config$ ls -l
total 8
-rw-rw-r-- 1 1883 1883 145 Feb 16 16:18 mosquitto.conf
-rwx------ 1 1883 1883 610 Feb 16 16:03 passwordfile
Although I have tried all different types of permissions and ownership combinations.
My current setup is functioning properly but the only way I could generate the passwordfile was by making it on my own computer and then copying it to my server running Chirpstack.
From inside my mosquitto container the permissions look like this:
/mosquitto/config # ls -l
total 8
-rw-rw-r-- 1 mosquitt mosquitt 145 Feb 16 21:18 mosquitto.conf
-rwx------ 1 mosquitt mosquitt 610 Feb 16 21:03 passwordfile
The command to add a user/pass works from inside the container, although it returns the following warnings:
/mosquitto/config # mosquitto_passwd -b passwordfile usertesting passwordtesting
Warning: File /mosquitto/config/passwordfile owner is not root.
Future versions will refuse to load this file.To fix this, use `chown root /mosquitto/config/passwordfile`.
Warning: File /mosquitto/config/passwordfile group is not root. Future versions will refuse to load this file
I read somewhere that the issue with changing the passwordfile from outside of the container could be due to mosquitto being installed in snap, and that restricts its permissions, although I’m not well versed enough in docker to understand what that really means or how to fix it.
Does anyone know what I would need to do to allow mosquitto access to change the passwordfile outside the container? I would prefer to be able to add gateway user/passwords without needing to enter the containers shell.
I’m happy to share any other relevant information on my setup/config files.
Might be worth mentioning I also cannot create a password file:
local@lorawan-ns:~/chirpstack-docker/configuration/mosquitto/config$ mosquitto_passwd -c newpasswordfile user
Password:
Reenter password:
Error: Unable to open file newpasswordfile for writing. Permission denied.