I currently have The Eclipse Mosquitto MQTT broker running on the Raspberry Pi 2, 3 and 4, Buster Raspbian, not to mention countless other variations of Debian and Ubuntu on various boards used at one time or another in the past (Orange Pi, various FriendlyArm boards and far more).
Below is the link I originally followed for the install – Mosquitto has been part of my standard install using “the script” for a long time – (last update April 2020). See my Bitbucket area and other parts of this blog for more on “the script”. I still use the Mosquitto broker having looked at several alternatives – the MOSCA Node-Red broker didn’t go anywhere – meanwhile, Mosquitto IS ready, works perfectly and it is also free and easy to use – I use it 24-7 in my own RPi4 installations here in Spain and in the UK, not to mention countless installations I’ve helped put together for others.
I started running Mosquitto on RPI2, then RPI3 and now RPI4. As an alternative to Mosquitto you could now take a look at node-red-contrib-Aedes – no other installation needed (you can also use Aedes alongside Mosquitto on a different port – just put the Aedes node somewhere on one of your pages and adjust the port number – then use the normal MQTT nodes to access it). I used npm to install it but apparently it installs for others through the Node-Red Pallette Manager.
This blog entry has been constructed over time going as far back as 2015…
I simply installed the repository then Mosquitto itself, nothing more.
This installation put a non-personalised config file at /etc/mosquitto – so in there was pointed to the directory /etc/mosquitto/conf.d – so I put my mosquitto.conf in there which was basically 2 lines…
allow_anonymous false password_file /etc/mosquitto/conf.d/passwords.txt
I’ve not yet put SSL in there but I certainly wasn’t going to start up the broker with NO security. I added a simple text file passwords.txt as above with a one-liner admin (colon) password where the password is encrypted using the Mosquitto password program for the PC (thankfully I already had a passwords file).
And that’s it really, stop the broker and restart it to make sure it takes notice of the config file..
sudo /etc/init.d/mosquitto stop sudo /etc/init.d/mosquitto start
And talk to it via something like MQTT SPY – subscribe to any old topic (“testing”, in my case) and try publishing to that topic. I’ve tested powering down and back up and all is well.
Easiest thing I’ve done all day.. oh, NO it wasn’t – I could not write to the etc/mosquitto/conf.d directory – the usual Linux security issues…. I did this.. most likely giving FAR too much access (if anyone wants to tell me what it SHOULD be, please do but don’t let’s get complicated)…
sudo chmod 777 ./conf.d
and from there on I could use my FTP described earlier and Notepad++ to create and edit the necessary files.