Linux Hack of the Week #19: Intro to MQTT
nless you have been typing under a rock for the past few years, you have heard about MQTT. Message Queue Telemetry Transport (MQTT) was developed in 1999 by IBM and has seen a resurgence of use thanks to the Internet of Things (IoT). MQTT uses TCP 1883 or 8883(TLS). The three main functional parts of MQTT include:
MQTT has many advantages such as not needing to continually poll, working really well with low latency connections (think LoRa) and allows for 1 to many relationships.
The heart of MQTT is a message and these messages send topics. Topics are hierarchical strings with a maximum length of 64k. They use a path format, i.e. door/state/0 or /drive/partition/40.
In this demonstration, we’ll use Ubuntu 18.04 with the Mosquitto package. Installation is as simple as apt-get install mosquitto for the server and apt-get mosquitto-clients for the client.tools:
Start the server process with service mosquitto start:
The first step is to subscribe to all messages. Use the command mosquitto_sub -v -t ‘#’
In another terminal, send a message with the mosquitto_pub command, our command will use the path example/data and the message “Hello World”:
Now, jump back to the server terminal and watch the message on the terminal:
Disk Monitoring Example
As an example, we can use MQTT to monitor the disk space on a partition. We’ll use forward tics to nest the df -h command in our message. The command is mosquitto_pub -t -m “`df -h`”
Back in the server terminal, we see the output:
This just scratches the surface of what can be done with MQTT. I’d encourage you to pick up an IoT device like the Onion Omega and try it out. As always, feel free to let us know if you have any questions: firstname.lastname@example.org.
Facing growing threats and a rapidly expanding attack surface, understaffed and alert-fatigued organizations need more efficient ways to eliminate their exposure to vulnerabilities. Automox is a modern cyber hygiene platform that closes the aperture of attack by more than 80% with just half the effort of traditional solutions.
Cloud-native and globally available, Automox enforces OS & third-party patch management, security configurations, and custom scripting across Windows, Mac, and Linux from a single intuitive console. IT and SecOps can quickly gain control and share visibility of on-prem, remote and virtual endpoints without the need to deploy costly infrastructure.
Experience modern, cloud-native patch management today with a 15-day free trial of Automox and start recapturing more than half the time you're currently spending on managing your attack surface. Automox dramatically reduces corporate risk while raising operational efficiency to deliver best-in-class security outcomes, faster and with fewer resources.