Hey Siri, manage my server…

Intro

I use Siri and Apple Homekit to automate some basic things – switching lights and heaters on/off, etc – and was wondering if there was some way I could use Siri to run tasks on my computers and servers at home.

Some googling showed me this was possible and also reasonably easy to set up – these are my notes on the process and some examples of what I’ve done with it so far.

Setup on iPhone

There’s a free Apple “Shortcuts” app for iPhones:

https://apps.apple.com/us/app/shortcuts/id915249334

which can perform a wide range of tasks, including – as of reasonably recently – the abiltiy to run scripts over SSH.

Open the Shortcuts App, click + and then Add action. These pics show the process from that point on:

Click on Add Action….

From here you fill out the details – the IP address of the remote computer, the user and password, and the path to the script you want to run.

Requirements

You need to have SSH setup and a working script you can run over SSH first.

On Ubuntu that means installing and configuring SSH as described here:

https://linuxize.com/post/how-to-enable-ssh-on-ubuntu-20-04/

On MacOS you need to enable Remote Login under Sharing here:

You also need a script that is executable as the user you are connecting with.

Obviously, be aware of the security risk of enabling tasks to be run remotely, etc.

Examples

Here are some I made earlier.

This one connects to my old Mac Pro (it runs Ubuntu) and runs a ‘shutdown’ script.

My /home/don/shutdown script simply contains “sudo init 0” and the ‘don‘ user is enabled for passwordless sudo.

and this one connects to the same host and powers on the attached monitor, that runs Firefox showing my CCTV/Zoneminder conosole:

The “/home/don/screenon” script contains this:

xset -display :0.0 dpms force on

and there’s a ‘screenoff’ that switches the display off when I don’t want it too.

For my iMac runnning MacOS I’ve added a shutdown script – useful when I don’t want to go and power it off manually.

I’ve ended up with a selection of shortcuts to power things on & off, and can now say “Hey Siri, CCTV on please“, or “Hey Siri, shutdown iMac please“, and Siri makes it so….

This setup enables me to run pretty much anything on a Linux or Mac host simply by asking Siri – it could trigger deployment pipelines, perform updates, start/stop/restart services…. anything you can put in a shell script.

If you have any interesting ideas or suggestions please let me know below.

Pin It on Pinterest

%d bloggers like this: