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.
Availability
Section titled “Availability”| Platform | Status |
|---|---|
| Android | Not available |
| iOS | Not available |
| Windows | Supported (via WSL) |
| macOS | Full support |
| Linux | Full 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.
What Is Mosh?
Section titled “What Is Mosh?”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.
Server Requirements
Section titled “Server Requirements”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/Debiansudo apt install mosh
# Fedora/RHELsudo dnf install mosh
# Arch Linuxsudo pacman -S mosh
# macOS (Homebrew)brew install moshThe server must also allow inbound UDP traffic on the Mosh port range (default: 60000-61000).
Client Requirements
Section titled “Client Requirements”macOS / Linux
Section titled “macOS / Linux”Install mosh via your package manager:
# macOSbrew install mosh
# Ubuntu/Debiansudo apt install mosh
# Fedorasudo dnf install mosh
# Archsudo pacman -S moshZestSSH calls the mosh binary directly from PATH.
Windows
Section titled “Windows”Mosh on Windows runs through WSL (Windows Subsystem for Linux):
- Install WSL:
wsl --install - Inside WSL, install mosh:
wsl apt install mosh - ZestSSH automatically runs
wsl mosh ...when connecting.
ZestSSH checks for both WSL availability and mosh installation inside WSL before attempting a connection.
Quick Start
Section titled “Quick Start”- Create a new connection and select Mosh as the protocol.
- Enter the hostname, port (SSH port for initial auth, default: 22), and identity.
- Tap Connect. ZestSSH will check that
moshis installed, then launch the session.
How It Works
Section titled “How It Works”- Availability Check — ZestSSH verifies the
moshbinary is available (viawhich moshon Unix, orwsl which moshon Windows). - 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).
- Process Launch — Spawns the
moshbinary as a subprocess (orwsl moshon Windows) withTERM=xterm-256color. - 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.
- 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.
Configuration
Section titled “Configuration”| Parameter | Default | Description |
|---|---|---|
| Host | (required) | Remote server hostname or IP |
| Port | 22 | SSH port for initial authentication |
| Identity | (optional) | SSH identity for authentication |
| Mosh Port Range | 60000:61000 | UDP port range for the Mosh session |
| Prediction Mode | adaptive | Local echo prediction: adaptive, always, never, or experimental |
Limitations
Section titled “Limitations”- 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-serverinstalled and UDP ports open. - No scrollback — Mosh does not support scrollback through its protocol. You can use
screenortmuxon 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.
Troubleshooting
Section titled “Troubleshooting””Mosh is not installed or not available”
Section titled “”Mosh is not installed or not available””- Verify
moshis installed: runwhich moshin a terminal (orwsl which moshon Windows). - On Windows, ensure WSL is installed and functioning:
wsl --status. - On macOS, install via Homebrew:
brew install mosh.
Connection fails after authentication
Section titled “Connection fails after authentication”- Check that
mosh-serveris 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.
Session hangs or shows stale content
Section titled “Session hangs or shows stale content”- 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.