Applications
Azure
Mosquitto 2 MQTT Broker on Ubuntu 24.04 on Azure User Guide
Overview
Eclipse Mosquitto is the canonical lightweight MQTT broker — used in millions of IoT deployments. The cloudimg image installs Mosquitto 2.x from Ubuntu noble universe with allow_anonymous false, a per-VM cloudimg user password rotated at first boot, and persistence enabled.
What is included:
- Mosquitto 2.x from Ubuntu 24.04 noble universe
- mosquitto-clients (mosquitto_pub, mosquitto_sub)
- Listener on TCP 1883 (MQTT)
- Per-VM
cloudimgpassword rotated at firstboot viamosquitto_passwd - Anonymous connections rejected
/etc/mosquitto/conf.d/cloudimg.confoverridesmosquitto.servicerunning asmosquitto:mosquitto- Persistence at
/var/lib/mosquitto - 24/7 cloudimg support
Prerequisites + Step 1-3
Standard B2s, NSG: TCP 22 + 1883 from your IoT/client networks.
Step 4: Verify
sudo systemctl status mosquitto.service --no-pager
sudo ss -tln | grep 1883

Step 5: Read the Password
sudo cat /stage/scripts/mosquitto-credentials.log

Step 6: Pub/Sub Round-Trip
PASS=$(sudo grep '^MOSQUITTO_PASSWORD=' /stage/scripts/mosquitto-credentials.log | cut -d= -f2-)
# Terminal A: subscribe to all topics
mosquitto_sub -h localhost -u cloudimg -P "${PASS}" -t '#' -v
# Terminal B: publish
mosquitto_pub -h localhost -u cloudimg -P "${PASS}" -t sensors/temp -m 22.5
mosquitto_pub -h localhost -u cloudimg -P "${PASS}" -t devices/01/state -m online

Step 7: Components
| Component | Path |
|---|---|
| Binary | /usr/sbin/mosquitto |
| Main config | /etc/mosquitto/mosquitto.conf |
| cloudimg overrides | /etc/mosquitto/conf.d/cloudimg.conf |
| Password file | /etc/mosquitto/passwd (mode 0640 root:mosquitto) |
| Persistence | /var/lib/mosquitto/ |
| Log | /var/log/mosquitto/mosquitto.log |
| Credentials | /stage/scripts/mosquitto-credentials.log |

Step 8: Security
- Restrict NSG so 1883 only reaches IoT clients
- Enable TLS on port 8883 with cert + ca files in conf.d/
- Per-client ACLs via
acl_filein conf.d/ - Patch monthly:
apt-get update && apt-get upgrade && reboot
Licensing
Mosquitto is EPL-2.0 / EDL-1.0 — free. cloudimg provides commercial support separately. support@cloudimg.co.uk.