I currently have The Eclipse Mosquitto MQTT broker running on the Raspberry Pi 2, 3 and 4, including Stretch and Buster Raspbian, not to mention countless other variations of Debian and Ubuntu on various boards used at one time or another (Orange Pi, various FriendlyArm boards and far more).
Below is the link I originally followed for the install - Mosquitto is now part of my standard install using "the script" - today (July 2019). 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 - I keep looking at the MOSCA Nod-Red broker - but it doesn't seem to be going anywhere - i.e. not ready for production apparently (that message has been on the relevant GIT repository for a long time) - well, Mosquitto IS ready and it is also free and easy to use - I use it 24-7 in my own installations here in Spain and back in my home in the UK (still currently on RPI3 on the latter), not to mention countless installations I've helped put together for others. I started running Mosquitto on RPI2, then RPI3 and now RPI4.
The rest of this blog entry was constructed 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…
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)…
and from there on I could use my FTP described earlier and Notepad++ to create and edit the necessary files.