Clear all

An iOS "app" to restart your Mac!

New Member
Joined: 5 years ago
Posts: 4
Topic starter  

In episode 899 Dave was wanting an iOS app that could allow a simple way to restart a Mac in situations like when your Mac is unresponsive.

Inspired by this, I have a little guide on how to use the iOS shortcuts app in order to create an "app" to allow you to simply do this. Saving you from manually launching and typing the command in an iOS terminal app.

Inside shortcuts there is a “Run script over SSH” action. Here we can add the host (local IP address of the Mac we want to restart), and the username and password for the Mac we need to connect to in order to action our restart command.


Now we can add the command:

sudo -S shutdown -r now

As we are not using an interactive terminal like you would on your Mac we need to use the -S option with sudo as we need to pass the password with the command to authenticate for sudo privileges.

In shortcuts we can add the "Text" action and put our Mac password inside. From this we can use the "Set variable" action to create a "Password" variable from the text input.


We need to place the "Text" and "Set variable" action above our “Run script over SSH” action. Then in the in the "input" section of “Run script over SSH” we can add our password variable in order to allow for sudo privileges.

Now we have our shortcut to restart a Mac. The first time you run it if you are using a password instead of a SSH key you'll need to confirm the SSH connection if but from then onwards it can simply run.

In order to have it as an app on your home screen you can to the shortcut settings to on the top right while inside the shortcut and use the "Add to Home Screen" option to add this action to your Home Screen.

You might also want to add the "Show Alert" action and add that to the very start of the shortcut, after all, no one wants to "get caught" and restart their Mac by mistake!

Some other links if you want some more security:

If you want to authenticate using an SSH key you can have a look at this guide: Remote control your Mac with your iPhone and SSH Key Shortcuts

If you don't want to store your Mac's password in plain text in the shortcut you can have a go at modifying the /etc/sudoers file on your Mac by having a look at this stack exchange post. I'm ok without doing that but that is up to personal preference.


Hope you found this useful!

Topic Tags
Dave Hamilton
Joined: 23 years ago
Posts: 589

This is fantastic. Thanks, @elliotjpb! I've built two Shortcuts on my iPhone and used one here this morning to restart a wonkily-stuck mac Mini.