Raspberry Pi – installing configuring running Mosquitto Server (MQTT)

Installation of MQTT V3.1

# apt-get update
# apt-get upgrade -y
# apt-get autoremove
# apt-get install mosquitto
# wget http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key
# apt-key add mosquitto-repo.gpg.key
# rm mosquitto-repo.gpg.key
#
cd /etc/apt/sources.list.d
# wget http://repo.mosquitto.org/debian/mosquitto-stretch.list
# apt-get update
# apt-get install mosquitto
# apt-get install mosquitto-clients
# service mosquitto Status
#
netstat -tln | grep 1883

# mosquitto_sub –d –t Topic
# mosquitto_pub –d –t Topic –m “Hello world!”
# mosquitto_sub -h 192.168.1.10 -t Topic
# mosquitto_pub -h 192.168.1.10 -t Topic -m „Hello world!“

Now that the MQTT broker is installed so we can add some basic security features

# cd /etc/mosquitto/conf.d
# vi mosquitto.conf
    allow_anonymous false
    password_file /etc/mosquitto/conf.d/passwd
    require_certificate false
# mosquitto_passwd -c /etc/mosquitto/conf.d/passwd <first user>
# mosquitto_passwd -b /etc/mosquitto/conf.d/passwd <second user> <password>

Leave a Reply

You must be logged in to post a comment.