Replay

Mosh

Mosh (Mobile Shell) is a remote terminal protocol designed for intermittent, roaming, and mobile connections. It uses UDP instead of TCP, which means your session can survive network switches, brief outages, and even putting your device to sleep — without disconnecting.

Echo has full built-in Mosh support, including automatic installation of mosh-server on the remote host, session persistence across backgrounding, and automatic reconnection after network disruptions.


How it works

When you connect to a server using Mosh, Echo performs a two-phase connection:

  1. SSH bootstrap — Echo opens a standard SSH connection to the remote host and launches mosh-server. The server responds with a UDP port number and a session key.
  2. UDP session — Echo closes the SSH connection and switches to a direct, encrypted UDP connection using the port and key from step 1. All terminal traffic flows over this UDP channel for the rest of the session.

Because Mosh uses UDP, sessions are not tied to a single TCP connection. If your IP address changes or the network drops momentarily, the session resumes automatically once connectivity returns — no reconnection required.


Setting up a Mosh server

Automatic installation

In most cases, you don't need to install anything manually. When Echo connects with Mosh and can't find mosh-server on the remote host, it will automatically download a verified, statically-linked mosh-server binary and install it to ~/.local/echo/mosh-server on the server. This process:

  • Detects the remote platform and architecture via uname (Linux and macOS are supported, on amd64, arm64, and armv7)
  • Downloads the correct binary from a trusted source (Blink's mosh-static-multiarch releases on GitHub)
  • Verifies the download against a SHA-256 checksum before uploading
  • Uploads the binary via SFTP and makes it executable
  • Caches the binary locally on your device so subsequent connections to other servers don't need to re-download it

Automatic installation requires no root or sudo access — the binary is installed into your home directory.

Auto-install supports Linux (amd64, arm64, armv7) and macOS (arm64, x86_64). If your server runs a different OS or architecture, you'll need to install mosh-server manually.

Manual installation

If you prefer to install mosh-server yourself, or if automatic installation isn't supported on your platform:

  • Debian / Ubuntu: sudo apt install mosh
  • Fedora / RHEL: sudo dnf install mosh
  • Arch Linux: sudo pacman -S mosh
  • macOS (Homebrew): brew install mosh

Echo searches common paths automatically, including /usr/bin, /usr/local/bin, /opt/homebrew/bin, and /home/linuxbrew/.linuxbrew/bin. If your mosh-server is installed somewhere else, you can set a custom path in the advanced settings.

Connection order

When connecting, Echo tries to find mosh-server in this order:

  1. Custom server path — if you've set one in the advanced settings, Echo tries that first.
  2. Echo's static binary ~/.local/echo/mosh-server on the remote host (from a previous auto-install).
  3. System mosh-server — searches the standard PATH plus common Homebrew / Linuxbrew locations.
  4. Auto-install — if none of the above succeed, Echo downloads, verifies, and uploads the correct binary automatically.

Firewall & UDP ports

Mosh requires UDP ports 60000–61000 to be open on the remote server. These are the default ports that mosh-server allocates for sessions. If your server uses a cloud provider, you'll need to add a rule to your security group or firewall configuration:

  • AWS: Add a custom UDP rule for ports 60000–61000 in your Security Group's inbound rules
  • GCP: Create a firewall rule allowing UDP 60000–61000
  • Azure: Add an inbound security rule for UDP 60000–61000 in your Network Security Group
  • DigitalOcean: If using Cloud Firewalls, add a UDP rule for 60000–61000

The SSH port (default 22) must also be open, since Echo uses SSH for the initial bootstrap phase.

If your server has ufw enabled, run: sudo ufw allow 60000:61000/udp

Adding a Mosh server

  1. Tap the + button to add a new server
  2. Tap the connection type dropdown to the left of the connection field and choose mosh
  3. Enter your connection details as usual: user@hostname or user@hostname:port
  4. Choose your authentication method (password or SSH key)
  5. Optionally tap Advanced in the Mosh section to configure additional settings
  6. Tap the checkmark to save

You can also change an existing server to use Mosh by editing it and switching the connection type dropdown from ssh to mosh.


Advanced settings

When the connection type is set to Mosh, a Mosh section appears with an Advanced link. This opens settings specific to the Mosh connection:

Server path

A custom path to the mosh-server binary on the remote host. Leave this empty to use the default auto-detection behaviour (which includes auto-install if needed). Only set this if mosh-server is installed in an unusual location, for example /opt/custom/bin/mosh-server.

Startup command

A command to run on the remote host after the Mosh connection is established. This is useful for automatically attaching to a tmux or screen session. For example:

  • tmux attach || tmux new — attach to an existing tmux session, or create a new one
  • tmux new-session -A -s main — attach to a named session or create it
  • screen -dR — reattach to a detached screen session

Prediction mode

Controls Mosh's local echo feature — predicting what the server will display before the response arrives, to reduce perceived latency. There are four modes:

  • Adaptive (default) — local echo is enabled automatically on slower connections and disabled on fast ones. This is the best choice for most users.
  • Always — always use local echo, even on fast connections. Useful if you want the snappiest feel regardless of network speed.
  • Never — never use local echo. All output is displayed only after the server responds. Use this if you find prediction distracting or if your workflow involves commands where predicted output is frequently wrong.
  • Experimental — aggressively echoes characters even when incorrect predictions are more likely. This can feel faster but may show brief visual glitches as predictions are corrected.

Session persistence

One of Mosh's biggest advantages is that sessions survive interruptions. Echo takes this further with built-in session persistence across app backgrounding.

Backgrounding

When Echo goes to the background (you switch apps, lock your device, etc.), it automatically:

  1. Triggers Mosh's state encoding — capturing the full protocol state of each active session
  2. Saves the encoded state and connection parameters to disk
  3. Shuts down the local Mosh client thread (the remote mosh-server keeps running)

When you return to Echo, it reads the saved state and reconnects to the still-running remote server. The session resumes exactly where you left off — your shell history, running processes, and terminal state are all preserved.

The remote mosh-server keeps running for at least 60 seconds (often much longer) after losing contact. Echo's session persistence has a 10-minute window, after which saved state is discarded.

Network recovery

If the network drops while a Mosh session is active — for example when toggling airplane mode, switching between Wi-Fi and cellular, or reconnecting a VPN — Echo handles recovery automatically:

  • Global network monitoring — Echo watches for network status changes. When connectivity returns after a drop, it force-cycles all active Mosh sessions through a suspend and resume, creating fresh UDP sockets.
  • Per-server monitoring — Echo also monitors the route to each specific Mosh server. This catches cases where your general internet stays up but the path to a particular server disappears — for example when a VPN or Tailscale disconnects and reconnects.
  • Automatic reconnection — if Mosh's UDP connection is lost, Echo retries with exponential backoff (1 second, 2 seconds, 4 seconds… up to 15 seconds between attempts) for up to 10 minutes.

In practice, this means you can put your phone in your pocket, walk between Wi-Fi networks, or toggle airplane mode on a flight, and your Mosh session will pick back up automatically once you have connectivity again.


Mosh vs SSH

Both connection types use the same authentication (password or SSH key) and the same server entry in Echo. The main differences:

SSHMosh
ProtocolTCPUDP (after SSH bootstrap)
Survives network changesNoYes
Survives backgroundingNoYes
Local echo / predictionNoYes
Port forwardingYesNo
SFTP / SCPYesNo
Firewall ports22 (TCP)22 (TCP) + 60000–61000 (UDP)
Server requirementsshd (always present)sshd + mosh-server

Use SSH when you need port forwarding, SFTP, or when you can't open UDP ports. Use Mosh when you're on the go, on unreliable networks, or when you want sessions that survive app backgrounding.


Troubleshooting

Having issues with Mosh? See the Mosh issues section of the troubleshooting guide, which covers mosh-server installation failures, bootstrap errors, UDP firewall issues, network switching, backgrounding, and display problems.

For general connection and authentication issues, see the full Troubleshooting guide. To learn about SSH key setup, see the SSH Keys guide.