Mosh vs SSH: what Mosh is, and when SSH plus Tmux does the job

11 November 2026 · Daniel Bilsborough · Reviewed 11 November 2026

Mosh (the mobile shell) is a remote terminal that keeps a session alive when your network changes or your laptop sleeps. It logs in with SSH, then hands the session over to its own UDP protocol. SSH runs over a single TCP connection, which ends when the network under it changes.

Mosh looks after the connection; Tmux, which runs on the server, looks after the session. They can be used together, or Tmux can carry the load over plain SSH. This page covers what each one does.

How Mosh works

When you run mosh user@host:

  1. Mosh connects with ordinary SSH, using your usual keys and ~/.ssh/config.
  2. Over that SSH connection it starts mosh-server on the remote machine, which picks a UDP port (60000 to 61000 by default) and a session key.
  3. The SSH connection closes. From then on the mosh-client on your machine and mosh-server talk directly over UDP, encrypted with that key.

Because UDP has no connection to break, the client can change IP address, from home wifi to a phone hotspot to office wifi, and the server just starts replying to the new address. A laptop that sleeps for an hour wakes up to the same session. Mosh also predicts what your keystrokes will do and shows them straight away, underlined until the server confirms, which makes a laggy link feel much closer to local.

Mosh vs SSH, side by side

SSHMosh
TransportTCP, one connectionSSH to start, then UDP
Network change (wifi to mobile)Connection dropsSession carries on
Laptop sleepUsually dropsSession carries on
Typing on a slow linkEach key waits for the serverLocal echo, confirmed later
ScrollbackYour terminal keeps itNot kept; only the current screen is synced
Port forwarding, agent forwarding, file transferYesNo (use SSH for these)
Server requirementsAn SSH serverSSH server, mosh-server installed, UDP ports open, a UTF-8 locale
Installed by defaultAlmost everywhereRarely

What Mosh can't do

Using Mosh

Install it on both ends:

# macOS
brew install mosh

# Ubuntu or Debian
sudo apt install mosh

Open the UDP ports on the server if it runs a firewall. With ufw:

sudo ufw allow 60000:61000/udp

Then connect the way you would with SSH:

mosh user@host

A few useful forms:

CommandWhat it does
mosh --ssh="ssh -p 2222" user@hostThe SSH login uses port 2222
mosh -p 60001 user@hostUse one fixed UDP port, so only that port needs opening
mosh user@host -- tmux new -A -s mainStart or re-attach a Tmux session inside Mosh. The -- is required; without it Mosh tries to read Tmux's flags as its own

SSH plus Tmux: the other way to survive a drop

Tmux runs on the server and keeps the session there whether or not anyone is connected. When an SSH connection drops, the session detaches and everything in it keeps running. Reconnect and attach, and you're back on the same screen:

ssh user@host
tmux new -A -s main

Compared with Mosh, that costs a reconnect after each drop, and there's no local echo on a laggy link. In return it needs nothing beyond SSH and Tmux, works through firewalls that block UDP, keeps a full scrollback, can be attached from any device, and leaves port and agent forwarding available. The attach and detach guide has the commands.

Running both is common, and they don't get in each other's way: mosh user@host -- tmux new -A -s main.

Mosh, SSH and Shell Drop on iPhone and iPad

Shell Drop is SSH only and doesn't have Mosh. Keeping a session alive falls to Tmux on the server: a dropped connection only detaches the session, Shell Drop reconnects after a drop and re-attaches your Tmux session, and restored tabs can re-attach to their sessions by name. Background sessions keep running while you use other apps.

If Mosh is a requirement, Blink Shell, Prompt 3, Termius and WebSSH support it on iOS; the best SSH client for iPhone and iPad roundup compares them. For the SSH-plus-Tmux route on a phone, see SSH on iPhone and SSH on iPad.

Questions

What is Mosh?

Mosh, the mobile shell, is a remote terminal program that replaces the interactive part of SSH. It logs in with SSH, then runs the session over UDP so it survives network changes and sleep, and it echoes your typing locally on slow links.

Does Mosh replace SSH?

Not entirely. Mosh uses SSH to log in and start mosh-server, so the server still needs SSH. It replaces only the interactive terminal session; port forwarding, file transfer and other SSH uses still need SSH.

Is Mosh secure?

Mosh authenticates through SSH and encrypts its own UDP traffic (AES-128 in OCB mode). The extra exposure is the UDP port range, 60000 to 61000 by default, which has to be open on the server.

Do I need Tmux if I use Mosh?

Often, yes. Mosh doesn't keep a scrollback history, and a Mosh session can't be re-attached from a new client. Running Tmux inside Mosh gives you both: Mosh holds the connection, Tmux holds the session.

Does Shell Drop support Mosh?

No. Shell Drop is SSH only. It reconnects after a drop and re-attaches your Tmux session. On iOS, Blink Shell, Prompt 3, Termius and WebSSH support Mosh.

Get Shell Drop on the App Store QR code for Shell Drop on the App Store Reading on a computer? Scan the code with your iPhone camera.