MQTT Username Password
What you will learn here about MQTT Username Password:
- How to secure MQTT broker on Raspberry PI using Username and Password
- How to secure MQTT broker on Linux system using Username and Password
- How to secure MQTT broker on Google Cloud using Username and Password
You need to follow same steps to secure your MQTT broker on Raspberry PI, Linux system as well as Google Cloud.
If you want to know how to secure MQTT broker on windows system please click on below link.
MQTT username password
Please follow the following steps to know how to add username and password to mosquitto or MQTT broker.
1)In order to add username and password to the MQTT broker, you need a MQTT broker. If you don’t know how to install MQTT broker please click on the below link.
Steps to Install MQTT Broker on Raspberry Pi
Steps to install MQTT Broker on Linux
Steps to Install MQTT Broker on Google Cloud
2)Assuming you have installed MQTT broker.
3)Now please open the Raspberry pi terminal or Linux system terminal or Google Cloud SSH Terminal
4)Please execute the following command to navigate in the mosquitto installed path
5)Now please execute the following command to create username and password file which is shown below.
6)Now please enter the password. you can enter anything as your password which is shown below.
7)Now please execute the following command to check the created username and password file which is shown below
8)Now please execute the following command to modify mosquitto.conf file
9)Now please add following lines in mosquitto.conf file which is shown below.
password_file /etc/mosquitto/pass
10)Now we need to restart mosquitto. Now please execute the following command to stop the mosquitto which is shown below.
11)Now please execute the following command to start the mosquitto which is shown below.
12)Now please execute the following command to publish data from the terminal using username and password which is shown below.
13)Now please execute the following command to publish data from the terminal using the wrong username and password and you will get the connection was refused error because username and password are wrong which is shown below.
Please click on the below link to become master in MQTT.