Mosh
Mosh (mobile shell) runs the terminal over UDP and keeps the session alive when the device’s IP address changes, for example when a phone moves from Wi-Fi to cellular. PocketCmd includes its own Mosh client, which talks to the standard mosh-server on your server.
Requirements
Section titled “Requirements”mosh-serveron the server. PocketCmd looks for it on the login shell’sPATHand in/opt/homebrew/bin,/usr/local/binand/usr/bin.- SSH access to the server. Mosh is started over SSH.
- Inbound UDP 60000–61000 open on the server. Each session uses one port from that range.
# Debian / Ubuntusudo apt install mosh
# Fedorasudo dnf install mosh
# macOS (Homebrew)brew install moshMore systems are listed in Compare Protocols.
Set up a Mosh server
Section titled “Set up a Mosh server”- Create or edit the server with its SSH address and credentials.
- Tap Test Connection. When the test finds
mosh-server, Mosh appears under Protocol. - Select Mosh and save.
Opening a terminal on the server now starts Mosh directly. PocketCmd logs in over SSH, runs mosh-server new and connects to the UDP port it reports. The loading screen shows “Starting mosh-server…” until the session is usable. If mosh-server cannot be started, you get a plain SSH shell instead and the message “Mosh unavailable, using SSH”.
You can also start a single Mosh session on an SSH server from its server sheet without changing the server’s protocol.
Session lifetime
Section titled “Session lifetime”A Mosh session keeps running on the server while the device is offline, asleep or on a different network, and the app reattaches to it when the connection returns.
The session also survives closing or restarting PocketCmd. The app stores the session key, sealed with your vault key and reconnects to the same mosh-server the next time you open it. It keeps the key for as long as the server’s MOSH_SERVER_NETWORK_TMOUT allows (read when mosh-server starts), and never longer than 7 days.
The server sheet’s Sessions list shows this device’s saved Mosh sessions with their remaining time (“expires in …”). Tap one to resume it, or long-press for Resume and Kill Session. Closing a session in the app ends its mosh-server as well.
Local echo
Section titled “Local echo”Mosh can show what you type before the server confirms it. PocketCmd turns this on automatically when the measured round trip is longer than 50 ms, and the server’s next screen update confirms or corrects each predicted character.
Scrollback
Section titled “Scrollback”Mosh synchronizes the screen, not the stream of output. When output scrolls faster than the link can carry it, intermediate lines never reach the device, so local scrollback can have gaps. For complete history, enable tmux for the server: PocketCmd starts the tmux session as the mosh-server command, and tmux keeps every line on the server. See tmux Integration.
Files, port forwards and jump hosts
Section titled “Files, port forwards and jump hosts”Files, workspaces and port forwards on a Mosh server use a separate SSH connection to the same host. Port forwards therefore do not roam with the Mosh session.
With a jump host, the SSH login that starts mosh-server goes through the chain, but the UDP traffic goes straight from the device to the server. The server’s Mosh ports must be reachable from your network.
Troubleshooting
Section titled “Troubleshooting”“Mosh unavailable, using SSH”
Section titled ““Mosh unavailable, using SSH””PocketCmd logged in but could not start mosh-server. Install Mosh on the server, or make sure mosh-server is on the PATH of a login shell or in one of the directories listed above.
The session connects, then stalls with no output
Section titled “The session connects, then stalls with no output”The SSH login works but the UDP packets do not arrive. Open UDP 60000–61000 in the server’s firewall and in any cloud security group or NAT rule in front of it.
Mosh is missing under Protocol
Section titled “Mosh is missing under Protocol”The server form only offers Mosh after Test Connection has found mosh-server. Install it, then run the test again.