TL;DR — Quick Summary

Mosh is a replacement for SSH that stays connected through network changes, Wi-Fi switching, and high latency. It uses UDP and shows local echo instantly.

Mosh keeps your remote sessions alive. Switch networks, close your laptop, ride through high latency — Mosh reconnects automatically and shows instant local echo.

Installation

# Install on BOTH client and server
# macOS
brew install mosh

# Ubuntu/Debian
sudo apt install mosh

# Arch Linux
sudo pacman -S mosh

# Open UDP ports 60000-61000 on server firewall
sudo ufw allow 60000:61000/udp

Usage

# Basic connection (replaces ssh)
mosh user@server

# Custom SSH port
mosh --ssh='ssh -p 2222' user@server

# Custom SSH port 443 (corporate firewalls)
mosh --ssh='ssh -p 443' user@server

# Specify mosh-server path
mosh --server=/usr/local/bin/mosh-server user@server

# Use with tmux/zellij (best combo)
mosh user@server -- tmux attach -t main

Comparison

FeatureMoshSSHEternal Terminal
ProtocolUDPTCPTCP
Survives roamingYesNoYes
Local echoYesNoNo
Port forwardingNoYesYes
File transferNoYes (scp)No
EncryptionAES-128VariousAES

Summary

  • Mosh keeps terminal sessions alive through network changes and sleep
  • UDP-based protocol survives Wi-Fi switching, cellular roaming, high latency
  • Instant local echo — no waiting for server round-trip
  • Uses SSH for authentication — your keys and config work automatically
  • Best combined with tmux or Zellij for persistent sessions