Skip to main content

Using SSH to log into a Mac remotely

  • I recently needed to log into a Mac I keep running at my home while I was away travelling. There are a few options for how to do this, the simplest of which is to connect to via SSH.
    • Since I ran into trouble at first so I wanted to write this post to make the process easier for you than it was for me.
  • I was away from home recently but still wanted to be able to log into a Mac mini I use as a home media server while I was away.
  • There are several solutions for this, including Screens 4 by X. But for my purposes, accessing the Mac’s file system using the terminal was plenty.
  • I recently wanted to log into a Mac mini I use as a home media server using the terminal from a remote location and ran into some trouble
  • Since it took a bit of googling and configuring to get things working, I thought I’d write the blog post I wish I’d found
  • I have a Mac Mini I use as a home media server
    • stores file archives + video files I play on my Apple TV using Plex
  • I wanted to have a way to ssh into the Mini so I could organize its files using vifm in my terminal rather than having to connect to the screen and use Finder
    • I find vifm much faster and more pleasant to use than Finder since its a keyboard-only way of managing files

✅ Steps

  1. Enable remote login on target Mac

  2. Note ssh command: ssh user@host

  3. Test on local network — command should work

    1. MOVE TO KITTY SSH POST: If using Kitty and noticing odd behaviour as you type after connecting, exit and try logging in again with this command: kitty +kitten ssh user@host.

      Truly convenient SSH

      r/linux4noobs - Comment by u/osu_randy on “Kitty terminal with ssh issues”

    2. In my case, Kitty didn’t work properly at first, but Terminal, iTerm or Warp all do

  4. Test on remote network - command will likely fail

    1. Why does my ssh user@host command work while on the same WiFi network, but timeout remotely?

      ssh: connect to host [IP_ADDRESS] port [PORT_NUMBER]: Operation timed out
    • answer: need to set up port forwarding from router’s WAN (public IP) address to your server (Mac)’s LAN (private IP) address
  5. Set up port forwarding on your router

    • Easiest to do this while you’re still at home
    1. See TP Link video for explanation of why this is needed
    2. For me, these steps were helpful:
      1. Note router’s WAN (public IP) address
      2. Note computer’s LAN (private IP) address on the DHCP client list
      3. Reserve server’s private IP address to prevent it from changing in the future
      4. Set up port forwarding

🐈 Kitty-specific steps?

  • Split this article into basic steps + Kitty steps?
  • Write two posts: one for the basic method above, and a second “awesome/supercharged/better” method with Kitty’s ssh kitten: Truly convenient SSH
  • This section shows predefining some settings Kitty should apply to the host machine, including copying over my .zshrc and other config files (so I’ll have them on any remote server)

Inbox