
The video walks through installing the Eclipse Mosquitto MQTT broker on Ubuntu 24.04 from the Ubuntu archive, confirming the broker answers with version 2.0.18, sending a first test message, then adding a password file and a short config so anonymous clients are refused. This companion guide gives you the same path in copyable form with expected results after each step, plus troubleshooting and cleanup. Watch it alongside the video at Install Mosquitto MQTT Broker on Ubuntu (Password-Locked).
MQTT is the message backbone of many self-hosted smart-home setups, carrying readings and commands between gear like Home Assistant, Zigbee2MQTT, Node-RED, and ESPHome devices. A broker with no password accepts publishes from anyone who can reach it, so the password lock in this guide is the part that matters most.
1883 free on the machine
The video installs both the broker and the command-line clients from Ubuntu's own archive, so there are no third-party repos or signing keys to add. Untested: the apt install and systemctl steps below follow the official documentation and the video but were not exercised in this guide's sandbox, which lacked root access.

sudo apt update && sudo apt install -y mosquitto mosquitto-clientsdpkg -l mosquitto mosquitto-clients | tail -2 and expect version 2.0.18sudo systemctl enable --now mosquittosystemctl is-active mosquitto and expect activemosquitto -h 2>&1 | head -1 and expect mosquitto version 2.0.18If the service is not active, run sudo systemctl status mosquitto and sudo journalctl -u mosquitto --no-pager | tail -20 to see why. A common cause is something already holding port 1883, which you can check with ss -tlnp | grep 1883.
A fresh Mosquitto install accepts anonymous local clients, which is why the video moves straight to a password file plus a three-line config file. The config options used here are documented in the mosquitto.conf man page and the password tool in the mosquitto_passwd man page.

sudo mosquitto_passwd -c /etc/mosquitto/passwd pilot, replacing pilot with your own username and choosing a strong password at the two prompts-c flag because it creates a new file and overwrites any existing password file, wiping other userssudo mosquitto_passwd /etc/mosquitto/passwd seconduser without -c/etc/mosquitto/conf.d/secured.conf containing listener 1883 on the first line, password_file /etc/mosquitto/passwd on the second line, and allow_anonymous false on the third linesudo systemctl restart mosquitto — Untested: the LAN-wide listener binding and the restart itself follow the official docs and were not exercised in this guide's sandboxIf the broker fails to restart after the config change, recheck the three lines for typos and confirm the password file path exists with ls -l /etc/mosquitto/passwd. Permission errors usually mean the file was created somewhere the mosquitto service user cannot read.
The video proves the setup with a publish and subscribe roundtrip on topic homelab/test, first open and then locked. This companion guide follows that same check so you know the broker routes messages and the password gate works.
mosquitto_sub -h 127.0.0.1 -p 1883 -t 'homelab/test' -C 1 in one terminal, then publish with mosquitto_pub -h 127.0.0.1 -p 1883 -t 'homelab/test' -m 'hello-mosquitto' in another, and expect the subscriber to print hello-mosquitto with exit code 0 on both sidesmosquitto_pub -h 127.0.0.1 -p 1883 -t 'homelab/test' -m 'sneaky' must fail with exit code 5 and the message Error: The connection was refused.mosquitto_pub -h 127.0.0.1 -p 1883 -u pilot -P 'YOUR-PASSWORD' -t 'homelab/test' -m 'secured-ok' must succeed, substituting your real username and password-u and -P flags and expect secured-ok to arriveIf the authed roundtrip fails, the usual suspects are a wrong password, quoting around a password with special shell characters, or testing against the wrong port. If anonymous clients still get through, confirm allow_anonymous false is spelled exactly and that you restarted the service after writing the file. Source and further options are on GitHub.
/etc/mosquitto/conf.d/secured.conf aside, and restart — then put the file back when donesudo systemctl disable --now mosquitto followed by sudo apt purge -y mosquitto mosquitto-clients and delete /etc/mosquitto/passwd and /etc/mosquitto/conf.d/secured.conf if they remain8883 and the dynamic-security plugin are documented next steps at Eclipse Mosquitto and were not covered in the video or this guide