2015-07-01 120 views
21

我使用了mosquitto_passwd命令來創建密碼文件。如何設置用戶名/密碼mosquitto?

mosquitto_passwd /etc/mosquitto/passwd admin 

我加入mosquitto.conf的路徑,我的密碼文件:

password_file /etc/mosquitto/passwd 

但是,當我訂閱或發佈不要求用戶名/密碼?

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 

我錯過了什麼?

回答

48

默認情況下,Mosquitto仍然允許匿名連接,即沒有提供用戶名/密碼的連接。 除了password_file項,您還需要:

allow_anonymous false 
+1

不要忘記給予好評並接受答案如果爲你工作。謝謝! – kartben

+0

我沒有足夠的15聲望upvote給你:D – datnq

+2

現在你有:) –

相關問題