How to Use Mosh on iOS
SSH was designed for a wired desktop that keeps one TCP connection open for hours. A phone breaks every assumption in that sentence: it changes networks mid-sentence, sleeps the radio when the screen locks, and moves between cell towers while you walk. Mosh was built for exactly that. It survives IP changes, tolerates high latency, and shows your keystrokes immediately instead of waiting for a round trip. Here is what it actually does, what your server needs, and how to turn it on.
Written by the GateShell team at Hefty Innovations
Step by step
- 1
Understand what Mosh changes
Mosh replaces SSH's transport, not its authentication. It authenticates over a normal SSH connection first, then hands the session to an encrypted UDP protocol called SSP that is not tied to any particular IP address. Because the session belongs to a cryptographic identity rather than a TCP socket, moving from Wi-Fi to cellular does not kill it; the session simply continues from the new address. It also echoes your keystrokes locally when it can predict them, so typing feels immediate even on a slow link.
- 2
Check what your server needs
Mosh needs a server-side counterpart and a UDP port range. Install the standard mosh-server package from your distribution ("sudo apt install mosh" on Debian/Ubuntu, "sudo dnf install mosh" on Fedora/RHEL), or use the GateShell Go agent, which includes a compatible server. Then allow inbound UDP on ports 60000-61000 through both the host firewall and any cloud security group. This is the step that trips most people up: SSH works on TCP 22, so a firewall that only allows 22 will let you connect and then fail to roam.
- 3
Enable Mosh for the server in GateShell
Open the server's settings and turn on Mosh. GateShell will bootstrap over your existing verified SSH connection, start the server-side process, and validate the first authenticated UDP packet before switching transports, so a misconfigured firewall surfaces as a clear message rather than a hung terminal. Mosh is a Pro feature.
- 4
Confirm it is actually using Mosh
Connect, and look for the link-quality indicator in the terminal toolbar. Green means the UDP transport is live; orange means the link is interrupted but the session is being held. If GateShell could not establish the UDP path it falls back to plain SSH and tells you why. It does not silently pretend to be roaming.
- 5
Test the thing you actually care about
Start something long-running, then switch from Wi-Fi to cellular, or lock the phone for a minute and come back. With Mosh the session is still there, mid-command, with your scrollback intact. With plain SSH it would have died at the first network change. Pair it with tmux auto-attach if you also want the work to survive the app being terminated entirely.
Frequently asked questions
What is the difference between Mosh and tmux?+
They solve adjacent problems and work well together. Mosh keeps your connection alive across network changes, so the session roams with you. tmux keeps your shell alive on the server independent of any connection, so a process survives even if the client disappears completely. Mosh protects against a network switch; tmux protects against the app being killed. Using both means neither event interrupts your work.
Does Mosh work if my server is behind a firewall?+
Only if inbound UDP 60000-61000 is open, in both the host firewall and any cloud security group. Mosh authenticates over TCP 22 and then moves to UDP, so a firewall allowing only port 22 produces a connection that works and then cannot roam. GateShell validates the UDP path during bootstrap and falls back to SSH with an explanation rather than leaving you with a session that silently stops updating.
Is Mosh less secure than SSH?+
No. Mosh authenticates you over a normal SSH connection, so your keys, host-key verification, and jump hosts all work exactly as before. Once authenticated it uses AES-128 in OCB mode over UDP for the session itself. What changes is the transport, not the trust model.
Do I need the GateShell agent to use Mosh?+
No. GateShell works with the standard mosh-server package from your distribution's repositories. The optional Go agent includes a compatible server if you would rather not install mosh separately, and it also brings metric history and alerts. For Mosh alone, the stock package is enough.
Why does my session still drop sometimes?+
Mosh keeps the session alive across network changes, but iOS can suspend an app entirely when it has been backgrounded for a long time, which ends the client process. The session itself is unaffected on the server side if you are running inside tmux. If drops happen immediately rather than after long backgrounding, the usual cause is UDP being blocked somewhere in the path, in which case GateShell will have fallen back to SSH.
Try it in GateShell
GateShell is a zero-backend SSH client for iPhone, iPad, and Mac, with no vendor cloud, no accounts and no telemetry. Everything above works out of the box.
Guide reflects GateShell's shipped features as of September 2026. Steps assume basic familiarity with SSH and the command line; server-side commands may vary by distribution. All product names, logos, and brands are property of their respective owners.