January 8, 2023

How to config a secure MQTT broker

Mahdad Ghasemian
@

Update system

$ apt-get update
$ apt-get upgrade

Create a folder

$ mkdir ./mosquitto-data

Go to the created folder and clone|run install-mqtt-broker script

note: change the following username and password

$ cd ./mosquitto-data
$ sudo curl -s https://raw.githubusercontent.com/MahdadGhasemian/mqtt-broker/main/install-mqtt-broker.sh | bash -s username password

The scripts will show following log

Script's log

  • copy the last line of the log and run it on your local system like this:

    $ sudo bash -c "echo "x.x.x.x mqtt-host-tekp" >> /etc/hosts"

  • copy client folder to your local, it has three files (ca.crt client.crt client.key)

How to configure the MQTTX client application

How to configure the MQTTX client app

Test message

Subscribe inside topic

Send and receive message