Skip to content

Mosh (Mobile Shell)

Mosh (Mobile Shell) is an alternative to SSH designed for unreliable or intermittent network connections. ZestSSH supports Mosh on desktop platforms by wrapping the system mosh binary and piping I/O to the built-in terminal emulator.

PlatformStatus
AndroidNot available
iOSNot available
WindowsSupported (via WSL)
macOSFull support
LinuxFull support

Mosh is a desktop-only feature. On mobile platforms (Android and iOS), Mosh requires native NDK/framework integration that is not yet implemented. ZestSSH will display a message suggesting you use SSH with keep-alive enabled as an alternative for unreliable mobile networks.

Mosh differs from SSH in several important ways:

  • UDP-based — After initial SSH authentication, Mosh switches to a UDP-based protocol (SSP — State Synchronization Protocol) that handles packet loss and reordering gracefully.
  • Roaming — Your session survives IP address changes (switching Wi-Fi networks, VPN reconnects) without disconnecting.
  • Local echo prediction — Mosh predicts the effect of keystrokes and displays them immediately, masking network latency.
  • No session loss — If your network drops temporarily, Mosh silently reconnects when connectivity returns. The session state is preserved on the server.

The mosh-server binary must be installed on the remote server. Mosh uses SSH for the initial connection and authentication, then switches to its UDP protocol.

Install on the server:

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

The server must also allow inbound UDP traffic on the Mosh port range (default: 60000-61000).

Install mosh via your package manager:

# macOS
brew install mosh
# Ubuntu/Debian
sudo apt install mosh
# Fedora
sudo dnf install mosh
# Arch
sudo pacman -S mosh

ZestSSH calls the mosh binary directly from PATH.

Mosh on Windows runs through WSL (Windows Subsystem for Linux):

  1. Install WSL: wsl --install
  2. Inside WSL, install mosh: wsl apt install mosh
  3. ZestSSH automatically runs wsl mosh ... when connecting.

ZestSSH checks for both WSL availability and mosh installation inside WSL before attempting a connection.

  1. Create a new connection and select Mosh as the protocol.
  2. Enter the hostname, port (SSH port for initial auth, default: 22), and identity.
  3. Tap Connect. ZestSSH will check that mosh is installed, then launch the session.
  1. Availability Check — ZestSSH verifies the mosh binary is available (via which mosh on Unix, or wsl which mosh on Windows).
  2. Argument Construction — Builds the command-line arguments with input validation:
    • Hostnames and usernames are validated against a strict character pattern to prevent shell injection.
    • Identity file paths are shell-quoted.
    • The port range is validated for numeric bounds.
    • The prediction mode is restricted to known values (adaptive, always, never, experimental).
  3. Process Launch — Spawns the mosh binary as a subprocess (or wsl mosh on Windows) with TERM=xterm-256color.
  4. I/O Piping — stdout and stderr from the mosh process are piped to the terminal widget. User input from the terminal is written to the process stdin.
  5. Cleanup — On disconnect, ZestSSH sends Ctrl+D (EOF) for graceful shutdown, waits briefly, then sends SIGTERM, and finally SIGKILL as a last resort. Any temporary SSH key files created for the session are securely deleted.
ParameterDefaultDescription
Host(required)Remote server hostname or IP
Port22SSH port for initial authentication
Identity(optional)SSH identity for authentication
Mosh Port Range60000:61000UDP port range for the Mosh session
Prediction ModeadaptiveLocal echo prediction: adaptive, always, never, or experimental
  • Desktop only — Not available on Android or iOS. Use SSH with keep-alive as an alternative on mobile.
  • Requires system mosh — ZestSSH does not bundle the mosh binary. It must be installed separately on the client machine.
  • Requires mosh-server — The remote server must have mosh-server installed and UDP ports open.
  • No scrollback — Mosh does not support scrollback through its protocol. You can use screen or tmux on the server for scrollback.
  • Terminal resize — PTY resize is best-effort. Mosh’s SSP protocol handles most resize scenarios, but a native PTY wrapper would be needed for full support.
  • No port forwarding — Mosh does not support SSH port forwarding, SFTP, or agent forwarding. Use a separate SSH connection for those features.
  • Windows requires WSL — Native Windows support is not available; Mosh runs through WSL.

”Mosh is not installed or not available”

Section titled “”Mosh is not installed or not available””
  • Verify mosh is installed: run which mosh in a terminal (or wsl which mosh on Windows).
  • On Windows, ensure WSL is installed and functioning: wsl --status.
  • On macOS, install via Homebrew: brew install mosh.
  • Check that mosh-server is installed on the remote server.
  • Verify UDP ports 60000-61000 are open in the server’s firewall.
  • If using a custom port range, ensure those ports are also open.
  • Mosh prediction can sometimes display stale output. Press Ctrl+L to force a screen refresh.
  • If the session is truly unresponsive, the network path may be blocked. Check that UDP traffic is allowed between your device and the server.

”Invalid hostname: contains unsafe characters”

Section titled “”Invalid hostname: contains unsafe characters””

ZestSSH validates hostnames against a strict pattern (alphanumerics, dots, hyphens, underscores, colons for IPv6, brackets) to prevent shell injection. Ensure the hostname does not contain spaces or special characters.

Q: Why is Mosh not available on mobile? A: Mosh requires a native binary (not a Dart/Flutter library). On desktop, ZestSSH calls the system mosh binary. On mobile, this would require building mosh as a native library and integrating it via platform channels, which is planned but not yet implemented.

Q: Can I use Mosh through a jump host? A: The initial SSH authentication uses the configured port and identity, but Mosh does not support jump host tunneling through its UDP protocol. Connect to the jump host via SSH first, then run mosh inside that session.

Q: Does Mosh encrypt traffic? A: Yes. Mosh uses AES-128-OCB for encryption after the initial SSH handshake. The UDP-based SSP protocol is encrypted and authenticated.