How to fix mosquitto_passwd overwriting all other users in the password file

Problem:

When running mosquitto_passwd like this:

example-4.sh

or with the -c parameter:

example-3.sh

the user is created but all other users who where previously listed in the file are deleted.

Solution

Create the first user using the -c flag in order to create the file if it does not exist

example-2.sh

Then create additional users using -b (batch mode),which allows you to specify the password on the command line:

example-1.sh

When using -b, old users will not be deleted.


Check out similar posts by category: MQTT