Remote control your Mac with your iPhone and SSH Key Shortcuts

macOS Preperation – Enable Remote Login on target Mac

  1. Open System PreferencesMacOS System Preferences Icon
  2. Find Sharing (or search for “remote”)
    MacOS System Preferences with
 remote searched for
  3. Turn on Remote Login. Enable “All Users” or add just one.
    Remote Login Selected on MacOS Sharing System Preferences
  4. Note the machine name (dougbeal-mb1.local), you will need it for the shortcut. You can also edit the name here.
    Circled Network Name

Create ssh shortcut on iOS

  1. Launch Shortcuts application. Search for shortcuts Application
  2. Create a new shortcut. Create Shortcut
  3. Add Action to shortcut. Add Action
  4. Search for ssh and select Run Script Over SSH. Search for ssh and find Run Script Over SSH
  5. Tap Show More. Run Script Over SSH select Show More
  6. In the Authentication section, select SSH Key. Shortcuts will automatically generate a key for you. Run Script Over SSH select Authentication, SSH Key
  7. Tap Script and swipe above keyboard and tap Shortcut Input. Change Run Script Over SSH script entry to Shortcut Input
  8. Tap on SSH Key and tap on Share Public Key. Get the public key to your mac (AirDrop, Handoff Clipboard, Apple Notes will all work). SSH Key Dialog with Share Public Key Highlighted
  9. Install public key on Mac

    Assumes public key is on the clipboard.

    1. make sure .ssh directory exists
    2. mkdir -p ~/.ssh

    3. append public key to authorized_keys file
    4. pbpaste >> ~/.ssh/authorized_keys

    Create a shortcut to put Mac Display to sleep

    1. Create a new shortcut
    2. add action TEXT with:
      pmset displaysleepnow

    3. add action Run Shortcut, choose shortcut from previous section

    Now when you run the shortcut, your display will go to sleep.

    #NovBaD #NaBloPoMo #challenge2of30 #challenge #automation #shortcuts #iOS #macOS #SSH

5 responses on “Remote control your Mac with your iPhone and SSH Key Shortcuts”

Leave a Reply