Hey Siri, reboot my server

iPhone with Siri

Have you ever been out to dinner and received a notification that one of your websites is down? Being afk when managing multiple servers can be stressful.

This happened to me recently, prompting the idea to create an Apple Shortcut allowing me to use Siri to reboot my servers remotely. Here's exactly how you can set this up for yourself.

Apple Shortcut

Step 1: Creating the Shortcut

Open the Shortcuts app on your iPhone, iPad, or Mac.

  • Tap the "+" icon to create a new Shortcut.
  • Name your Shortcut clearly, e.g., "Reboot my server."

Step 2: Adding Server Selection

If you're managing multiple servers, add a menu for selecting the server:

  • Add the "Choose from Menu" action.
  • Give it a clear title like "Select Server to Reboot."
  • List all your servers clearly (e.g., Web Server, Database Server, Dev Server).

For each server option, perform these actions:

  1. Text Action: Enter your server's IP address.
  2. Set Variable: Give it a clear name, such as server_ip, and set it to the Text action's output.

Step 3: Confirmation Prompt

To avoid accidental reboots:

  • Add an "Ask for Confirmation" action after setting the variable.
  • Prompt example: "Are you sure you want to reboot this server?"

Step 4: SSH Command for Rebooting

🔑
You'll need to add ssh keys for your iPhone, laptop, and iPad in order to connect to each server.

Now, add the reboot command:

  • Add a "Run Script Over SSH" action.
  • Set Host to your variable server_ip.
  • Set the appropriate SSH username (e.g., root).
  • Set authentication via SSH key for better security.
  • Paste the following reboot command to gracefully reboot without causing transport errors:
sudo reboot >/dev/null 2>&1 &

Step 5: Confirming the Reboot Success

To verify your server rebooted successfully without relying on actions unavailable on iPhone:

  • Add a "Wait" action (about 60 seconds).
  • Add another "Run Script Over SSH" action, using the following simple command to test connectivity:
echo "Server is online"

Then, add an "If" action to check the result:

  • If the action returns an error, show an alert: "⚠️ Server unreachable after reboot!"
  • Otherwise, show an alert: "✅ Server rebooted successfully!"

Step 6: Using Siri

Now, whenever a server goes down, simply invoke Siri and say:

"Hey Siri, reboot my server"

Download and Try It Yourself

You can download the Shortcut I created below. Customize it to your server IPs and quickly manage your infrastructure remotely!

Feel free to leave comments or suggestions on how you've modified or improved your version of this shortcut.