SwiftServer
Terminal

Mosh

Terminal sessions that survive network changes and sleep, how SwiftServer bootstraps mosh-server, and how to troubleshoot UDP.

Mosh keeps a terminal session alive through network changes, weak signal, and your device sleeping. Switch from Wi-Fi to cellular mid-session and the shell is still there. SwiftServer speaks the Mosh protocol natively — the server just needs mosh-server installed.

Turn Mosh on for a machine

Mosh is a per-machine connection mode:

  1. Edit the machine and set Connection to Mosh.
  2. Optionally adjust Server Executable (defaults to mosh-server on the PATH — set an absolute path if yours lives elsewhere).
  3. Save. The machine's terminal action becomes Start Mosh Terminal.

How a session starts

SwiftServer first connects over SSH exactly as usual (same authentication, same host key checks), starts mosh-server through that connection, then hands the session to UDP and closes the SSH channel. There is no password inside the Mosh protocol itself — the secret session key is exchanged over the encrypted SSH bootstrap, and all Mosh traffic is encrypted with it.

Test Connection in the machine editor verifies the SSH bootstrap; the UDP side is verified the first time you start the terminal.

Requirements

  • mosh-server installed on the server (apt install mosh, dnf install mosh, brew install mosh, …).
  • UDP reachable from your device to the server on the negotiated port. By default mosh-server picks a port in its standard range (60000–61000); open that range, or set a custom one.

To pin the port range, enable Use Custom UDP Port Range in the machine editor and set First UDP Port / Last UDP Port — SwiftServer passes them to mosh-server so you can open exactly one small range in your firewall.

Jump hosts and proxies

Mosh bootstraps through your configured jump host or proxy, but the UDP session connects directly. If the machine's address is only reachable through the proxy, set a directly reachable UDP Host in the machine's Mosh settings.

Life of a Mosh session

  • Change networks and the session follows — SwiftServer pins the UDP flow to a resolved address and rebuilds the connection as paths change. You may briefly see "Mosh is rebuilding its UDP connection", then "Mosh UDP connection restored".
  • If the server stays silent, the status line counts it: "No Mosh server contact for N seconds".
  • When the server ends the session (for example mosh-server is killed), the terminal reports "The Mosh server ended the session." Reconnecting starts a fresh session.

Troubleshooting

"mosh-server exited with status 127" (or similar with "command not found") — mosh-server is not installed or not on the PATH for non-interactive SSH. Install Mosh, or set the absolute path in Server Executable.

"mosh-server did not print MOSH CONNECT within 8 seconds" — the bootstrap ran but produced no session line. Usually a shell startup script printing noise or blocking; try running mosh-server manually over SSH to see its output.

Connects, then hangs at a blank terminal — the SSH bootstrap worked but UDP is blocked. Open the UDP port range in every firewall between you and the server (cloud security groups included), or set a custom range you can open.

"Could not resolve the Mosh UDP host" — the hostname doesn't resolve to an IPv4/IPv6 address from your device. Use an IP, or set UDP Host explicitly.

Mosh sessions include a Mosh Diagnostics section in the disconnect dialog with the full bootstrap and connection log — check it first, and include it if you write to support.

On this page