Raspi remote control via SMS (working with TOTP passwd auth)

There’s fun here for both tinkerers and perhaps many other home automation, farming or industrial users - all with a Waveshare modem and Raspberry Pi.

I wanted to share this project to invite extra project ideas, code improvements, or perhaps even additional feature requests. All code and instructions to install as a running service at boot is shared here: SMS-to-Shell on Github

With this little project you can either securely send SMS shortcut command keywords or full shell commands directly to a Raspi. (Communications and security features rely only on the SMS network, meaning interactivity is acheived without the need for any cloud subscription or full time internet access - great for for low power or intermittently awake devices.)

After sending a shell command, incoming messages are converted into shell input, executed, and the resulting shell output is replayed back to the sender’s phone number via SMS. All SMS command outputs above a configurable character limit will be paginated over multiple SMS messages/pages.

An important consideration for automation over SMS is security. This project supports a variety of security levels and configurations using phone number access lists, restriction of commands to only a whitelist and for full zero trust, one-time passwords (TOTP with QRcode) can be enforced before every command if desired.

The code itself has a reasonable level of error checking and I’ve not been able to break it by sending massive or weird commands or characters in a few months of messing with it. The script is aimed to support a wider range of modems, languages and even some proprietary command syntax that might vary between modem manufacturers, so it should be workable on just about any serial or usb AT modem. This project tries to balance efficiency, simplicity and flexibility to be able to support a range of low power hardware without requiring exotic python library support that may not be readily available in other Linux distros like OpenWRT etc.

1 Like

That’s awesome Dave!

Adding runtime passwords is a super great idea.
This means you could use it for remote user authorization.

From the github:

Windows adaption seems possible with minor project edits

Remote user authentication is a major headache for windows sysadmins. If you’re on the go usually the only solution is a laptop and a VPN. SMS would be a great alternative.

If it ever comes up for me, I’ll give it shot and you might be seeing a pull requests with a branch for powershell 4.6. :heart:

Hi Dave,

What an awesome polished software project! I’ve made a note to link to this thread from our SMS guide for the Pi, as you’ve documented and implemented this perfectly from what I can see.

Amazing stuff!! :heart_eyes:

Thankyou James,

Yes please feel free to link to it as its all been done with Waveshare gear from your store! I’ve made some final improvements to the code and docs so its now more or less a v1.0 proof of concept that others are welcome to build on and help me improve. It would be good to see what other uses the home autmotation and maker community can find for it.

A project extension I’m currently adding to it is an SMS / Lora / MQTT gateway interface for simple IOT remote control integrations. The aim is a small tech footprint and no need for operating any public internet facing systems, cloud APIs or other IOT carrier depencencies/limitations/network mgmt overheads etc. For encyption in transit, a Telegram to MQTT / Lora gateway could likely apply the same mesage parsing approach.


1 Like