{"id":23565,"date":"2019-05-06T23:33:15","date_gmt":"2019-05-07T06:33:15","guid":{"rendered":"https:\/\/m2msupport.net\/m2msupport\/?page_id=23565"},"modified":"2019-06-02T12:10:29","modified_gmt":"2019-06-02T19:10:29","slug":"mqtt-user-authentication","status":"publish","type":"page","link":"https:\/\/m2msupport.net\/m2msupport\/mqtt-user-authentication\/","title":{"rendered":"MQTT &#8211; User Authentication"},"content":{"rendered":"<p>MQTT broker can be setup to requires username and password before clients can connect to the broker.<\/p>\n<h3><strong>Related Topics<\/strong><\/h3>\n<ul>\n<li><a href=\"https:\/\/m2msupport.net\/m2msupport\/how-mqtt-works\/\">How MQTT works?<\/a><\/li>\n<li>MQTT \u2013 Connect to Broker\n<ul>\n<li><a href=\"https:\/\/m2msupport.net\/m2msupport\/mqtt-connect-to-eclipse-public-mqtt-server\/\">Connect to Eclipse public MQTT Server<\/a><\/li>\n<li><a href=\"https:\/\/m2msupport.net\/m2msupport\/mqtt-connect-to-mosquitto-broker-on-local-windows-machine\/\">Connect to Mosquitto MQTT server on local Windows machine<\/a><\/li>\n<\/ul>\n<\/li>\n<li><a href=\"https:\/\/m2msupport.net\/m2msupport\/mqtt-topics\/\">MQTT Topics<\/a><\/li>\n<li><a href=\"https:\/\/m2msupport.net\/m2msupport\/mqtt-publish\/\">MQTT Publish<\/a><\/li>\n<li><a href=\"https:\/\/m2msupport.net\/m2msupport\/mqtt-subscriber\/\">MQTT Subscribe<\/a><\/li>\n<li><a href=\"https:\/\/m2msupport.net\/m2msupport\/mqtt-quality-of-service-qos\/\">MQTT Quality of Service (QoS)<\/a><\/li>\n<li><a href=\"https:\/\/m2msupport.net\/m2msupport\/mqtt-keep-alive-pingreq-pingresp\/\">MQTT \u2013 Keep Alive with PINGREQ and PINGRESP<\/a><\/li>\n<li><a href=\"https:\/\/m2msupport.net\/m2msupport\/install-mqtt-broker-mosquitto-in-windows\/\">Install MQTT broker Mosquitto in Windows<\/a><\/li>\n<li><a href=\"https:\/\/m2msupport.net\/m2msupport\/mqtt-user-authentication\/\">Mosquitto Broker \u2013 Enable user authentication<\/a><\/li>\n<li><a href=\"https:\/\/m2msupport.net\/m2msupport\/mqtt-user-name-and-password-authentication-to-mqtt-broker-connection\/\">MQTT Broker connection with user name and password<\/a><\/li>\n<\/ul>\n<h2><strong>Setup Mosquitto MQTT broker to use username and password<\/strong><\/h2>\n<p>Create a file with username and password. Add the username and password separated by colon in separate lines as shown below.<\/p>\n<p><a href=\"https:\/\/m2msupport.net\/m2msupport\/wp-content\/uploads\/2019\/05\/mqtt_user_accounts.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-23566\" src=\"https:\/\/m2msupport.net\/m2msupport\/wp-content\/uploads\/2019\/05\/mqtt_user_accounts.png\" alt=\"\" width=\"620\" height=\"305\" srcset=\"https:\/\/m2msupport.net\/m2msupport\/wp-content\/uploads\/2019\/05\/mqtt_user_accounts.png 620w, https:\/\/m2msupport.net\/m2msupport\/wp-content\/uploads\/2019\/05\/mqtt_user_accounts-300x148.png 300w, https:\/\/m2msupport.net\/m2msupport\/wp-content\/uploads\/2019\/05\/mqtt_user_accounts-600x295.png 600w\" sizes=\"auto, (max-width: 620px) 100vw, 620px\" \/><\/a><\/p>\n<p>Encrypt the file that contains the password.<\/p>\n<p><a href=\"https:\/\/m2msupport.net\/m2msupport\/wp-content\/uploads\/2019\/05\/mqtt_password_encrypt.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-23567\" src=\"https:\/\/m2msupport.net\/m2msupport\/wp-content\/uploads\/2019\/05\/mqtt_password_encrypt.png\" alt=\"\" width=\"579\" height=\"224\" srcset=\"https:\/\/m2msupport.net\/m2msupport\/wp-content\/uploads\/2019\/05\/mqtt_password_encrypt.png 579w, https:\/\/m2msupport.net\/m2msupport\/wp-content\/uploads\/2019\/05\/mqtt_password_encrypt-300x116.png 300w\" sizes=\"auto, (max-width: 579px) 100vw, 579px\" \/><\/a><\/p>\n<p>Verify that the password file is encrypted,<\/p>\n<p><a href=\"https:\/\/m2msupport.net\/m2msupport\/wp-content\/uploads\/2019\/05\/mqtt_password_encrypted_file.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-23568\" src=\"https:\/\/m2msupport.net\/m2msupport\/wp-content\/uploads\/2019\/05\/mqtt_password_encrypted_file.png\" alt=\"\" width=\"972\" height=\"226\" srcset=\"https:\/\/m2msupport.net\/m2msupport\/wp-content\/uploads\/2019\/05\/mqtt_password_encrypted_file.png 972w, https:\/\/m2msupport.net\/m2msupport\/wp-content\/uploads\/2019\/05\/mqtt_password_encrypted_file-300x70.png 300w, https:\/\/m2msupport.net\/m2msupport\/wp-content\/uploads\/2019\/05\/mqtt_password_encrypted_file-768x179.png 768w, https:\/\/m2msupport.net\/m2msupport\/wp-content\/uploads\/2019\/05\/mqtt_password_encrypted_file-600x140.png 600w\" sizes=\"auto, (max-width: 972px) 100vw, 972px\" \/><\/a><\/p>\n<p>Once the password file is created, edit the mosquitto.conf file to enable the username and password by,<\/p>\n<ul>\n<li>set allow_anonymous to false<\/li>\n<li>Set the folder location of the the password_file<\/li>\n<\/ul>\n<p><a href=\"https:\/\/m2msupport.net\/m2msupport\/wp-content\/uploads\/2019\/05\/mosquitto_conf.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-23569\" src=\"https:\/\/m2msupport.net\/m2msupport\/wp-content\/uploads\/2019\/05\/mosquitto_conf.png\" alt=\"\" width=\"659\" height=\"441\" srcset=\"https:\/\/m2msupport.net\/m2msupport\/wp-content\/uploads\/2019\/05\/mosquitto_conf.png 659w, https:\/\/m2msupport.net\/m2msupport\/wp-content\/uploads\/2019\/05\/mosquitto_conf-300x201.png 300w, https:\/\/m2msupport.net\/m2msupport\/wp-content\/uploads\/2019\/05\/mosquitto_conf-600x402.png 600w\" sizes=\"auto, (max-width: 659px) 100vw, 659px\" \/><\/a><\/p>\n<p><\/p>\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>MQTT broker can be setup to requires username and password before clients can connect to the broker. Related Topics How MQTT works? MQTT \u2013 Connect to Broker Connect to Eclipse public MQTT Server Connect to Mosquitto MQTT server on local &hellip; <a href=\"https:\/\/m2msupport.net\/m2msupport\/mqtt-user-authentication\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"software_howto.php","meta":{"footnotes":""},"class_list":["post-23565","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/m2msupport.net\/m2msupport\/wp-json\/wp\/v2\/pages\/23565","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/m2msupport.net\/m2msupport\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/m2msupport.net\/m2msupport\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/m2msupport.net\/m2msupport\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/m2msupport.net\/m2msupport\/wp-json\/wp\/v2\/comments?post=23565"}],"version-history":[{"count":3,"href":"https:\/\/m2msupport.net\/m2msupport\/wp-json\/wp\/v2\/pages\/23565\/revisions"}],"predecessor-version":[{"id":26665,"href":"https:\/\/m2msupport.net\/m2msupport\/wp-json\/wp\/v2\/pages\/23565\/revisions\/26665"}],"wp:attachment":[{"href":"https:\/\/m2msupport.net\/m2msupport\/wp-json\/wp\/v2\/media?parent=23565"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}