Deployment guide

Mosquitto 2

Overview

Eclipse Mosquitto is a lightweight MQTT broker and the standard choice for IoT messaging. This SecureAnyCloud image installs Mosquitto 2.x from the Ubuntu noble universe repository with allow_anonymous set to false, so anonymous connections are rejected.

The image also rotates the SecureAnyCloud user's password on the first boot of every VM and enables persistence.

What you get:

  • Mosquitto 2.x from the Ubuntu 24.04 noble universe repository
  • mosquitto-clients (mosquitto_pub, mosquitto_sub)
  • A listener on TCP 1883 (MQTT)
  • A per-VM SecureAnyCloud password, rotated at first boot with mosquitto_passwd
  • Anonymous connections rejected
  • Overrides in /etc/mosquitto/conf.d/sac.conf
  • mosquitto.service running as mosquitto:mosquitto
  • Persistence at /var/lib/mosquitto
  • 24/7 SecureAnyCloud support

Prerequisites

Deploy the image on a Standard B2s VM. Configure the network security group (NSG) to allow inbound TCP 22 and TCP 1883 from your IoT and client networks.

4

Verify

Check that the service is running and that the broker listens on port 1883:

sudo systemctl status mosquitto.service --no-pager sudo ss -tln | grep 1883
5

Read the Password

Read the per-VM password from the credentials file:

sudo cat /stage/scripts/mosquitto-credentials.log
6

Pub/Sub Round Trip

Subscribe in one terminal and publish from another to confirm that the broker accepts the login and delivers messages:

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

Components

These are the files that make up the installation:

Component Path

Binary /usr/sbin/mosquitto

Main config /etc/mosquitto/mosquitto.conf

SecureAnyCloud overrides /etc/mosquitto/conf.d/sac.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

8

Security

  • Restrict the NSG so that port 1883 only reaches IoT clients.
  • Enable TLS on port 8883 with certificate and CA files in conf.d/.
  • Use per-client ACLs through acl_file in conf.d/.
  • Patch monthly with apt-get update && apt-get upgrade && reboot.

Licensing

Mosquitto is licensed under EPL-2.0 / EDL-1.0 and is free to use. SecureAnyCloud provides commercial support separately. Contact sales@secureanycloud.com.

Deploy on Azure

Launch Mosquitto 2 MQTT Broker on Ubuntu 24.04 LTS on Azure with 24/7 support from SecureAnyCloud.

View this image

Need Help?

Our support team is available 24/7.

sales@secureanycloud.com

Deploy on Azure