SSH, tmux, mosh or PandaSend: reaching your Mac's terminal from a phone
There's no single right way to reach your Mac's terminal from a phone. There are four common ones, and they solve different parts of the problem. Here's what each needs, what it's good at, and where it gets painful.
The three problems to solve
Every option has to answer the same questions:
- Getting there. How does your phone reach your Mac, especially from outside your home network?
- Staying there. What happens to the running program when your phone loses signal, sleeps, or switches from Wi-Fi to cellular?
- Typing there. How do you press Esc, Tab, Ctrl-C and the arrow keys on a phone keyboard?
Option 1: SSH
Turn on Remote Login in System Settings → General → Sharing, install an SSH app on your phone (Blink Shell, Termius and Prompt are popular on iPhone), and connect with a key. The full setup, including reaching the Mac from outside your home, is in how to SSH into your Mac from your iPhone.
- Getting there: easy on your home network. From outside, you need a route in: forwarding a port on your router (which exposes SSH to the internet), a VPN, or a mesh network app.
- Staying there: this is SSH's weak spot on phones. When the connection drops, the programs started over it usually go with it.
- Typing there: good SSH apps add extra keys above the keyboard.
Option 2: SSH plus tmux
tmux keeps a session running on the Mac independent of your connection:
tmux new -s work # start a named session, then run your agent inside it
# press Ctrl-b, then d, to detach
tmux attach -t work # later, from any connection: pick up where you were
- Staying there: solved, as long as you started tmux before the thing you want to keep.
- The cost: another tool to learn, with its own key bindings, scrolling model and copy mode, all of which are fiddly on a touch screen.
Option 3: mosh (plus tmux)
Mosh replaces the SSH connection with one designed for mobile networks: it survives roaming between networks and sleep, and it shows your typing instantly instead of waiting for the round trip.
- Needs: mosh on the Mac (
brew install mosh), an app that supports it, and UDP ports open to the Mac (60000–61000 by default), which some networks block. - Staying there: much better than plain SSH, but the session still ends if the mosh server exits, so many people still run tmux inside it.
Option 4: PandaSend
PandaSend is narrower than all of the above: it only gives you terminal sessions on your own Mac, but it handles all three problems itself.
- Getting there: at home, your phone connects directly over Wi-Fi. Away, your Mac and phone both connect out to a relay, so there's nothing to open on your router. The relay only carries end-to-end encrypted traffic.
- Staying there: every session runs in a background process on the Mac from the start, so there's nothing to remember. Reconnecting sends only the output you missed.
- Typing there: the phone side has a key bar for Esc, Tab, Ctrl and arrows, keeps the line you're typing above the keyboard, and turns swipes into scrolling even inside full-screen programs.
- Limits: Mac only for now, no file transfer, and it can't take over a terminal already running in another app.
Which one should you use?
| If you… | Use |
|---|---|
| manage Linux servers or cloud machines | SSH + tmux, or mosh + tmux |
| already have SSH working and like it | Keep it; add tmux if you don't have it |
| need file transfer or port forwarding | SSH |
| want your Mac's agents and builds on your phone with nothing to set up | PandaSend |
| spend a lot of time on patchy mobile networks | mosh, or PandaSend |
They also mix fine: plenty of people will keep SSH for servers and use PandaSend for the Mac on their desk.