20200331 Mosquitto Pi Setup
This is how I have setup and configured my Mosquitto server running on Raspbian Buster lite.
- write the Raspbian Buster lite image with win32diskimager to the SDHC card
- configure the Raspbian with raspi-config like I have documented here
-
update the Raspbian packets
sudo apt-get update
-
perform the update
sudo apt-get dist-upgrade
-
install the mosquitto server according to App Code Labs Introduction to IoT: Build an MQTT Server Using Raspberry Pi
-
verify that
/etc/mosquitto/mosquitto.conf
contains the lineinclude_dir /etc/mosquitto/conf.d
-
create a
conf.d
directory in/etc/mosquitto/
mkdir /etc/mosquitto/conf.d
-
create a password for a user with the name
user
in/etc/mosquitto/conf.d/
sudo mosquitto_passwd -c mosquitto_passwordfile_user user
-
create the file
/etc/mosquitto/conf.d/mosquitto.conf
with this content :allow_anonymous false password_file /etc/mosquitto/conf.d/mosquitto_passwordfile_user
At the end I have achieved this :
- the mosquitto server is started automatically when Raspbian is booted
- my
/etc/mosquitto/conf.d/mosquitto.conf
is included by/etc/mosquitto/mosquitto.conf
- the mosquitto server does not allow anonymous login anymore
- the only allowed user is
user
and you have to use the password coded in/etc/mosquitto/conf.d/mosquitto_passwordfile_user