Mosh or SSH?
A short comparison to decide which to use for a connection.
Both give you a shell. They fail differently.
SSH Mosh
Survives IP change no yes
Survives sleep, drops session ends session resumes
Typing on a slow link lags instant (local echo)
Port forwarding yes no
Agent forwarding yes no
Through a jump host yes no
Needs TCP 22 UDP range + mosh-server
Scrollback yes (client) screen only (use tmux)
Pick Mosh when
- You work from a phone or tablet and move between networks.
- The connection is slow or drops now and then.
- You mostly type commands, edit and read output.
Pick SSH when
- You need port forwarding or agent forwarding. See Mosh and SSH agent forwarding: why ssh -A does not carry over.
- You must go through a jump host.
- The host or its firewall does not allow UDP.
- You copy files (use SFTP).
- The host has no
mosh-server.
Together
Many people connect with Mosh and run tmux inside it. Mosh keeps the connection alive. tmux keeps the work: if the Mosh session ends, the programs keep running on the host and you reattach.