How Does Mosh Differ from SSH?

Updated

Mosh is a replacement for interactive SSH terminals that keeps your session alive when your network changes, your connection drops, or your laptop sleeps, and it echoes your typing instantly instead of waiting for the server. It is the better choice when you work over Wi-Fi, cellular, or long-distance links; plain SSH remains fine for stable wired connections or for non-interactive tasks like file transfer and remote command execution.

The core differences at a glance

Dimension SSH Mosh
Connection after changing networks (e.g., Wi-Fi to LTE) Typically lost; you reconnect Roams automatically and stays logged in
After a drop or laptop sleep Session ends; you start over Warns you, then resumes when the network returns
Typing feedback Waits for the server's reply before showing your keystrokes Instant local echo for typing, deleting, and line editing
Transport TCP UDP-based protocol
Packet loss Handled poorly; lag builds up Handled gracefully; frame rate adapts to network conditions
Interrupting a runaway process Can be sluggish when buffers are full Control-C works reliably because buffers don't fill up
Login and credentials Native Uses SSH to log in with the same credentials, then runs mosh-server over UDP
Privileges and background processes — No superuser needed, no daemon; client and server run as an ordinary user and last only for the connection
Character set — UTF-8 only
Platforms — GNU/Linux, BSD, macOS, Solaris, Android, Chrome, and iOS

Roaming and intermittent connectivity

Mosh "automatically roams as you move between Internet connections." The site's example is using Wi-Fi on a train, Ethernet in a hotel, and LTE on a beach while staying logged in. Most network programs, including SSH and web apps, lose their connections after roaming.

The same resilience covers interruptions. You can put your laptop to sleep and wake it later with the connection intact. If the Internet connection drops, Mosh warns you, and the connection resumes when network service comes back.

Responsive typing and honest predictions

SSH shows your own typing only after the server replies, which feels laggy on slow links. Mosh responds instantly to typing, deleting, and line editing, and it does this adaptively, including inside full-screen programs like emacs and vim. On a bad connection, predictions that haven't been confirmed are underlined so you aren't misled about what the server has actually received.

How the connection is established

Mosh doesn't listen on network ports or authenticate users itself. The mosh client logs in to the server via SSH using the same credentials you already use (password or public key). It then runs mosh-server remotely and connects to it over UDP. In practice, this means:

  1. Input: you run mosh with a destination, the same way you would use ssh.
  2. Action: the client authenticates over SSH, starts mosh-server on the remote host, and switches to a UDP session.
  3. Expected result: an interactive terminal that survives roaming and drops and echoes your keystrokes immediately.

Two conditions follow from this design: the remote host must be able to run mosh-server, and UDP traffic between the two machines must be permitted. Neither step requires superuser privileges.

Terminal behavior

Mosh is a command-line program like ssh and runs inside xterm, gnome-terminal, urxvt, Terminal.app, iTerm, emacs, screen, or tmux. It was designed from scratch and supports only UTF-8, which the project says fixes Unicode bugs found in other terminals and in SSH. Because its UDP protocol handles packet loss gracefully and sets the frame rate based on network conditions, it doesn't fill network buffers, so Control-C always works to halt a runaway process.

When to choose which

  • Choose Mosh for interactive shell work on laptops and mobile devices, especially over Wi-Fi, cellular, or long-haul links, and when you need sessions to survive sleep, drops, or network switches.
  • Stay with SSH when you need a stable, traditional TCP session, are working on a fast and reliable wired network, or are doing non-interactive work such as transfers and scripted remote commands.
  • Check first that the server side can run mosh-server and that UDP is allowed through the path between client and server; otherwise the SSH login will succeed but the Mosh session won't come up.

Mosh is free software, and the project distributes it for the platforms listed above.