Every Mac has an SSH server built in; it’s just switched off. Turn it on, give your iPhone a way to reach the Mac when you’re not on the same Wi‑Fi, sign in with a key instead of a password, and keep the session running when the phone locks. That’s four steps, and they’re the same whichever app you use on the phone.
Updated . We make Hako, one of the apps below.
1. Turn on Remote Login
- On the Mac, open System Settings → General → Sharing and turn on Remote Login.
- Click the i beside it to choose which users may sign in. Turn on “Allow full disk access for remote users” if you’ll work in Desktop, Documents or Downloads; without it, macOS’s privacy protection keeps an SSH session out of them.
- Under the switch, macOS shows the command to sign in, such as
ssh [email protected]. The part after@is the Mac’s address on your own network.
On the same Wi‑Fi, that address works from your phone already. Try it before going further, so you know the Mac’s side is right.
2. Reach the Mac from anywhere with Tailscale
Away from home, your-mac.local means nothing, and opening port 22 on your router invites the whole internet to guess your password. Tailscale is the simpler and safer way: a private network between your own devices, free for personal use.
- Install Tailscale on the Mac and on the iPhone, and sign in to the same account on both.
- In the Tailscale app, find the Mac’s name, such as
your-mac, or its100.x.y.zaddress. - Use that as the host in your SSH app. It works on Wi‑Fi, on cellular, and on someone else’s network, and only your own devices can reach it.
3. Sign in with a key
Most iPhone SSH apps can create a key for you and show its public half, a line starting with ssh-ed25519. Add that line to the Mac:
mkdir -p ~/.ssh && chmod 700 ~/.ssh
echo 'ssh-ed25519 AAAA… iphone' >> ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keysThen set the host in your app to use the key. The private half never leaves your phone, and you stop typing your Mac’s password on a phone keyboard.
4. Keep the session alive: tmux or Mosh
iOS suspends an app soon after you leave it, and plain SSH drops when the phone sleeps or moves from Wi‑Fi to cellular. Whatever you were running dies with it. Two tools fix that, and they work well together.
- tmux keeps the shell running on the Mac whether you’re connected or not. Install it with
brew install tmux, and start each visit withtmux new -A -s main, which reattaches to the session if it’s there and starts it if not. - Mosh replaces the connection itself with one that survives sleep and network changes and echoes your typing at once on a slow link. Install it on the Mac with
brew install mosh, and pick Mosh in an app that supports it. On an Apple Silicon Mac, if the app says it can’t findmosh-server, set its path to/opt/homebrew/bin/mosh-server.
Which app to use on the iPhone
| Mosh | Built around | |
|---|---|---|
| Termius | Yes | Saved hosts synced across devices, SFTP, port forwarding |
| Blink Shell | Yes | A configurable command line and long sessions at an iPad keyboard |
| Secure ShellFish | No | Remote files in the Files app, tmux sessions with Handoff |
| Prompt 3 | Yes | Saved servers, reusable commands, and a Mac app too |
| La Terminal | Yes | Resource monitors, command search and file tools |
| Moshi | With Pro | Coding agents, with an optional helper for their status |
| Hako | Yes | Coding agents across several Macs, in one list |
For a shell, files and servers, the first five are mature, and the comparisons go through each. Hako is for a narrower job: you SSH into your Mac to check on Claude Code, Codex or another coding agent. It runs them in herdr and lists every pane on every Mac on your iPhone, iPad and Mac, sorted by who needs you, with an agent’s question on your Lock Screen. Each pane is still a real terminal over SSH or Mosh, and Hako connects to any Mac or Linux box as a plain terminal too. It’s coming soon to the App Store. Claude Code on iPhone compares the ways to reach an agent.
Keep your Mac awake
A sleeping Mac doesn’t answer SSH. On a desktop Mac, turn on “Prevent automatic sleeping when the display is off” in System Settings → Energy. On a laptop, stay plugged in, or start a long job with caffeinate -i in front of it to hold off idle sleep until it exits.
Questions
Can I SSH into my Mac without Tailscale?
On the same network, yes: use the .local address Remote Login shows. From outside, you’d forward a port on your router to the Mac and keep its public address current, which exposes SSH to the internet. If you do, turn passwords off and use keys only. A private network such as Tailscale or WireGuard avoids all of that.
What about Tailscale SSH?
Tailscale SSH lets Tailscale handle sign-in instead of keys, but on a Mac it needs the open-source tailscaled rather than the Tailscale app from the App Store or Tailscale’s site. With the app, use the Mac’s own Remote Login as above, over the Tailscale address.
Does this work on an iPad?
Yes. Every app above runs on iPad, and the Mac’s side is the same. Blink Shell is the one built around a hardware keyboard. Hako runs on iPad with iPadOS 17 or later.
Can I run Claude Code or Codex over SSH from my phone?
Yes. Start the agent inside tmux on the Mac, then attach from your phone; it keeps working while the phone is locked. What plain SSH can’t do is tell you when the agent stops to ask you something. Claude Code notifications on iPhone covers that, and Codex on iPhone the other ways to reach Codex.
Is it safe?
SSH encrypts everything, a key can’t be guessed the way a password can, and with Tailscale your Mac is only reachable from your own devices. Hako adds no account and no server that sees your sessions: they go straight from your phone to your Mac. See what leaves your devices.