Debian mqtt代理-acl文件

Debian mqtt代理-acl文件,debian,mqtt,mosquitto,broker,Debian,Mqtt,Mosquitto,Broker,我在Debian 9上安装了mosquitto apt-get install mosquitto mosquitto-clients 你重新开始了吗 服务重启 测试它 mosquitto_pub -d -t My/Topic2 -m "Hello MQTT" 没有错误消息 创建了一个密码 mosquitto_passwd -c /etc/mosquitto/passwd myUsername 创建了一个ACL文件 touch /etc/mosquitto/aclfile nano /et

我在Debian 9上安装了mosquitto

apt-get install mosquitto mosquitto-clients
你重新开始了吗 服务重启

测试它

mosquitto_pub -d -t My/Topic2 -m "Hello MQTT"
没有错误消息

创建了一个密码

mosquitto_passwd -c /etc/mosquitto/passwd myUsername
创建了一个ACL文件

touch /etc/mosquitto/aclfile
nano /etc/mosquitto/aclfile
关于这一内容:

# This affects access control for clients with no username.
topic read myTopic/#

# This only affects clients with username "myUsername".
user myUsername
topic myTopic/#

# This affects all clients.
pattern write $SYS/broker/connection/%c/state
将acl_文件的路径插入到此文件

nano /etc/mosquitto/mosquitto.conf

acl_file /etc/mosquitto/aclfile
password_file /etc/mosquitto/passwd
因此,计划是用户“myUsername”可以在“myTopic”中发布,而所有其他用户(包括来宾)只能阅读

我已经在另一台服务器上运行了此配置,但在这种情况下出现了问题 第一次测试时,我忘记将密码_文件路径添加到mosquito.conf 并得到错误:连接被拒绝,如果我想这样发布 如果我只想订阅的话

mosquitto_sub -d -t myTopic/test
好的,我解决了这个问题,但是现在我可以不使用用户名/密码发布了

对于科塞,我重新启动了:

service mosquitto restart
所以如果我发送

mosquitto_pub -d -t myTopic/test -m "Access denied is expected"
我没有收到任何错误,看起来消息已经发布了

如果我打开第二个shell(也从远程机器打开) 我可以订阅

mosquitto_sub -d -t myTopic/test
但是,如果我将某个内容发布到此主题,则不会收到任何内容(Ping正在工作)

对我的两个问题有什么想法吗

PS:我不是Linux专业人士 因此,如果您需要更多信息,请向我提供正确的信息如何获得这些信息

编辑:如果我使用

ps -efc 
这是莫斯基托的唯一入口

mosquit+ 736 1 TS 19 21:36 ? 00:00:02 /usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf
日志中

nano /var/log/mosquitto/mosquitto.log
我明白了

但对于谷歌来说,这应该在去年就已经解决了


我使用的是mosquitto 1.4.10版

如果不允许用户发布某个主题,那么发布就会自动失败。这是为MQTT设计的(至少是MQTT v3.x)

如果要防止客户端不传递用户名/密码,可能还需要添加
allow_anonymous false


要获取最新版本的mosquitto,请按照上的说明安装正确的ppa

遇到相同问题,并发现它与用户名/客户端id中的
/
有关。来源:


删除“/”使其再次工作。

检查mosquitto是否实际使用了您提供的配置文件。(日志应列出启动时在第2行使用的路径配置文件,或者应在
ps-efc
的输出中列出)。Mosquitto不使用配置文件,除非明确告知。如果我使用ps-efc,这是Mosquitto mosquit+736 1 TS 19 21:36的唯一条目?00:00:02/usr/sbin/mosquitto-c/etc/mosquitto/mosquitto.conf是否正确?编辑问题以包含更新信息。但是是的,它看起来像是在使用配置文件。因此,您需要检查日志文件(其位置应在conf文件中)。如果日志nano/var/log/mosquitto/mosquitto.log I get ACL拒绝访问具有危险客户端id“mosqpub/7977-Debian-93”的客户端,那么如果没有显示任何明显的日志,则可能需要将日志级别调高(请参阅mosquitto.conf手册页和
log\u type
选项)ACL拒绝访问具有危险客户端id“mosqpub/356-h2700629”的客户端,但关于谷歌,这应该已经在去年修复。它可能已经修复,但我们不知道您实际运行的mosquitto的版本。计划是用户“myUsername”可以在“myTopic”中发布,所有其他用户(包括来宾)只能阅读,因此,allow_anonymous设置为true。如果使用-I参数发送,日志中的错误消息将消失。不管你怎么说,如果我插入“-u username-P password”无效,我希望收到一条拒绝访问的消息:)对不起,我不能投票给你的答案,分数要少一些:(
/* Check whether the client id or username contains a +, # or / and if
 * so deny access.