mosquitto安全策略

    mosquitto服务配置安全策略

    修改mosquitto.conf文件

    allow_anonymous=false                                                  //不允许匿名

    password_file /home/chc/mqtt/mosquitto-1.4.8/pwfile     //用户名和密码文件

    acl_file /home/chc/mqtt/mosquitto-1.4.8/acl                    //权限文件

    之后把执行命令生成用户文件mosquitto_password -c /home/chc/mqtt/mosquitto-1.4.8/pwfile username  

    拷贝一份aclfile.example文件  cp aclfile.example acl

    编辑acl文件添加用户

    user username        //用户

    topic #                     //允许主题 #是允许所有主题

    

    user username2

    topic write news/#   //允许username2发布new/XXX主题

    user username3

    topic read news/#    //允许username3读取new/XXX主题

猜你喜欢

转载自zhuangtiejun.iteye.com/blog/2404608