Linux Hack of the Week #19: Intro to MQTT

Unless 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:

  • Sensor
  • Broker
  • Subscriber

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.

Installation

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:

Try it!

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:

Conclusion

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: support@automox.com.

About Automox

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.

Get Instant Updates on Vulnerabilities

Subscribe to receive Automox vulnerability alerts

Reduce your threat surface by up to 80%

Make all of your corporate infrastructure more resilient by automating the basics of cyber hygiene.

Take 15 days to raise your security confidence!
Start a Free Trial