explaingit

mobile-shell/mosh

13,905C++Audience · ops devopsComplexity · 3/5Setup · moderate

TLDR

Mosh is a remote terminal application like SSH that stays connected when you switch networks, lose Wi-Fi, or put your laptop to sleep, it roams automatically and shows instant typing feedback even on laggy or high-latency connections.

Mindmap

mindmap
  root((Mosh))
    What it does
      Remote terminal
      Network roaming
      Lag prediction
    How it works
      SSH for auth
      UDP for session
      Local keystroke prediction
    Requirements
      UTF-8 terminal
      UDP 60000-61000
      Server binary installed
    Limitations
      No X forwarding
      No port forwarding
      No non-interactive modes
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Stay connected to a remote server while commuting or switching between Wi-Fi and mobile data, without the session ever dropping.

USE CASE 2

Work interactively on a high-latency VPN or slow connection with responsive typing because Mosh predicts keystrokes locally.

USE CASE 3

Replace SSH for daily remote development when you frequently close your laptop lid or change locations.

Tech stack

C++

Getting it running

Difficulty · moderate Time to first run · 30min

Requires installing the mosh server binary on the remote host and opening UDP ports 60000-61000 in the firewall.

In plain English

Mosh is a remote terminal application, similar in purpose to SSH: it lets you connect to another computer over the internet and run commands on it. The key difference is how it handles unstable or changing network conditions. Where a standard SSH session drops the moment you lose your Wi-Fi or wake your laptop from sleep, Mosh keeps the session alive and picks up where you left off once connectivity returns. When you switch networks, such as moving from a coffee shop's Wi-Fi to your phone's cellular data, Mosh detects your new IP address automatically and continues the session without any manual reconnection. This roaming behavior is built into the protocol itself. Mosh also handles slow or high-latency connections better than SSH. It runs a local prediction model that guesses how each keystroke will appear on screen before the server confirms it, then immediately shows that prediction to you. The predicted characters are underlined until the server responds. For most typing and arrow-key navigation, the result is a terminal that feels responsive even when your connection is lagging. Full-screen applications like text editors and IRC clients work correctly with this system. Under the hood, Mosh uses SSH only to establish the initial connection and verify your identity. After that, the session moves to UDP, which lets it tolerate dropped packets and changing addresses. By default, it picks a port between 60000 and 61000. Your firewall needs to allow UDP traffic on that range for Mosh to function. There are some things Mosh does not do: it does not support X forwarding, port forwarding, or any of the non-interactive modes that SSH handles. It requires a UTF-8 terminal environment and needs its server binary installed on the remote host alongside the client binary on your machine.

Copy-paste prompts

Prompt 1
My SSH sessions drop whenever I switch from office Wi-Fi to my phone hotspot. Show me how to install and configure Mosh on my Ubuntu server and macOS laptop to replace SSH for interactive sessions.
Prompt 2
I need to open UDP ports 60000-61000 in my server's ufw firewall so Mosh can connect. Show me the exact commands and explain why UDP is needed instead of TCP.
Prompt 3
Walk me through the difference between how SSH and Mosh handle network interruptions, I want to understand why Mosh stays alive when SSH dies.
Open on GitHub → Explain another repo

← mobile-shell on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.