eclipse-mosquitto / mosquitto

Eclipse Mosquitto - An open source MQTT broker
https://mosquitto.org
Other
9.12k stars 2.41k forks source link

Error reading password file: Permission denied #3131

Open dippes opened 1 month ago

dippes commented 1 month ago

Hello

I am trying in vain to generate a password with ‘mosquitto_passwd’, no matter which directory I use, I always get an error message.

root@hp-server:~# mosquitto_passwd -c /etc/mosquitto/conf.d/ dippes
Error reading password file: Permission denied

Has anyone successfully fixed this?

ckrey commented 1 month ago

The first parameter is supposed to be the name of the password file, not the directory.

Try

mosquitto_passwd -c /etc/mosquitto/conf.d/pwfile dippes

See also:

mosquitto_passwd is a tool for managing password files for mosquitto.

Usage: mosquitto_passwd [-H sha512 | -H sha512-pbkdf2] [-c | -D] passwordfile username
       mosquitto_passwd [-H sha512 | -H sha512-pbkdf2] [-c] -b passwordfile username password
       mosquitto_passwd -U passwordfile
 -b : run in batch mode to allow passing passwords on the command line.
 -c : create a new password file. This will overwrite existing files.
 -D : delete the username rather than adding/updating its password.
 -H : specify the hashing algorithm. Defaults to sha512-pbkdf2, which is recommended.
      Mosquitto 1.6 and earlier defaulted to sha512.
 -U : update a plain text password file to use hashed passwords.

See https://mosquitto.org/ for more information.