How to SSH into your Mac from your iPhone (step by step)
SSH is the classic way to use your Mac's terminal from somewhere else, and it works from an iPhone. This guide sets it up properly: Remote Login on the Mac, an SSH app on the phone, key-based login instead of your password, and a safe way in from outside your home network.
Step 1: Turn on Remote Login on your Mac
- Open System Settings → General → Sharing.
- Turn on Remote Login.
- Click the ⓘ next to it. Set Allow access for to Only these users and keep just your own account. The same panel shows the command to connect, like
ssh you@your-mac.local.
Remote Login is macOS's built-in SSH server. It accepts connections on port 22 from your local network.
Step 2: Find your Mac's address
On the same Wi-Fi, the .local name from the Sharing panel usually works. If it doesn't, use the Mac's local IP address:
ipconfig getifaddr en0
That prints something like 192.168.1.23. (On a Mac with Ethernet, try en1 if en0 prints nothing.) Local addresses can change when your router restarts; a DHCP reservation in your router's settings keeps it fixed.
Step 3: Connect from your iPhone
Install an SSH client. Termius and Blink Shell are the popular ones on iOS. Create a new host with:
- Hostname: the
.localname or IP address from step 2 - Port: 22
- Username: your Mac account's short name (run
whoamion the Mac to see it)
Connect, accept the Mac's host key the first time, and log in with your Mac password. You now have your Mac's shell on your phone. Next, get rid of that password.
Step 4: Switch to key-based login
A password can be guessed or phished. An SSH key can't be typed into a fake prompt, and it's much longer than any password you'd type on a phone.
- Create a key on the phone. Both apps above can generate one; choose Ed25519. The private key stays on the phone. Copy the public key, a single line that starts with
ssh-ed25519. - Add it to your Mac. In an SSH session (or on the Mac itself), run:
mkdir -p ~/.ssh && chmod 700 ~/.ssh echo 'ssh-ed25519 AAAA...your-public-key... iphone' >> ~/.ssh/authorized_keys chmod 600 ~/.ssh/authorized_keys - Tell the app to use the key for this host, and connect again. It shouldn't ask for your password.
Then turn off password logins
Once the key works, stop the SSH server from accepting passwords at all. macOS reads extra settings from /etc/ssh/sshd_config.d/:
printf 'PasswordAuthentication no\nKbdInteractiveAuthentication no\n' | sudo tee /etc/ssh/sshd_config.d/100-keys-only.conf
Turn Remote Login off and on again in System Settings to apply it. Test from the phone before you close your Mac session, so a typo can't lock you out.
Step 5: Reach your Mac from outside your home
Everything so far works on your home Wi-Fi. On cellular, your phone can't see 192.168.x.x addresses. You have three options:
- A mesh VPN (recommended). Install Tailscale (or a similar WireGuard-based tool) on the Mac and the phone and sign in to both. The Mac gets a private address that works from anywhere, with no router changes. Use that address as the hostname in your SSH app.
- A reverse tunnel through a server you control. More moving parts, covered in how to access your Mac remotely without port forwarding.
- Port forwarding on your router. This puts your Mac's SSH server on the public internet, where it gets scanned for weak logins within minutes. If you do it, use keys only (step 4), and know that many home connections are behind carrier-grade NAT, where port forwarding simply doesn't work.
Step 6: Keep your session alive
iOS pauses apps you're not looking at, so switching apps or locking the phone usually drops the SSH connection. Whatever was running in that session may be killed with it. Two fixes:
- Run long jobs inside tmux on the Mac (
brew install tmux, thentmux new -s work), and reattach after reconnecting withtmux attach -t work. See keeping a process running after you disconnect. - Use mosh, which keeps a session alive across network changes and sleep. It needs its own server installed on the Mac (
brew install mosh) and an app that supports it, such as Blink Shell.
And keep the Mac awake while you're away, or there'll be nothing to connect to: caffeinate and the Mac's sleep settings.
The shorter route
Steps 1 to 6 add up to Remote Login, an SSH app, keys, a VPN, tmux and a sleep setting, and you still type terminal shortcuts on a phone keyboard. That's the right setup if you administer servers from your phone anyway.
If what you want is to check on the builds, deploys and coding agents running on your own Mac, PandaSend Terminal does it without any of those pieces. Sessions run on your Mac and keep running no matter what the phone does. You pair your phone once by scanning a QR code, and then open the same live session in your phone's browser, at home or on cellular, end-to-end encrypted. The phone gets a key bar with Esc, Tab, Ctrl and arrows, and a notification when a session is waiting for you. Remote Login stays off, and nothing on your Mac is exposed to the internet. There's a side-by-side comparison in SSH, tmux, mosh or PandaSend.