I used the mosquitto_passwd
command to create a password file.
mosquitto_passwd /etc/mosquitto/passwd admin
I added the path to my password file in mosquitto.conf
:
password_file /etc/mosquitto/passwd
But when i subscribe or publish it doesn't require username/password?
mosquitto_sub -t '#' -d
Client mosqsub/19032-Dell sending CONNECT
Client mosqsub/19032-Dell received CONNACK
Client mosqsub/19032-Dell sending SUBSCRIBE (Mid: 1, Topic: #, QoS: 0)
Client mosqsub/19032-Dell received SUBACK
Subscribed (mid: 1): 0
What did I miss?
By default, Mosquitto will still allow anonymous connections, i.e. connections where no username/password is provided.
In addition to the password_file
entry, you also need:
allow_anonymous false