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

Feature Mosh SSH Eternal Terminal
Protocol UDP TCP TCP
Survives roaming Yes No Yes
Local echo Yes No No
Port forwarding No Yes Yes
File transfer No Yes (scp) No
Encryption AES-128 Various AES

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