Fall 2026brianmars.comBuilt at EGBT Technologies
ReferenceRemote access

mosh and tmux

A connection that survives wifi changes and laptop sleep, and a shell that survives the connection.

Names and addresses are placeholders. The list says what each one stands for.

What it does here

Three layers, each covering a different failure. Tailscale finds the box on any network, mosh keeps the connection alive across network changes and sleep, and tmux keeps the shell on the server so nothing is lost if the link dies, and you can reattach from another machine.

From the manual

Canonical setup

mosh has to be installed on both ends. tmux plugins come from tpm, the tmux plugin manager.

Server: tmux plugin manager
sudo apt install -y tmux mosh
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
Each client
brew install mosh          # macOS
sudo apt install -y mosh   # Debian, Ubuntu

Upstream: mosh, tpm, tmux-continuum.

Edited for this build

In this build

  1. Sessions survive a server reboottmux-resurrect saves them and tmux-continuum restores them when the tmux server starts.
  2. One clean host entryThe MagicDNS name and your user, and nothing else.
  3. A one-word connectdev opens mosh and attaches to the main session, creating it if needed.
  4. Mouse on, long history, vi keys
~/.tmux.conf
set -g mouse on
set -g history-limit 50000
setw -g mode-keys vi

set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-continuum'
set -g @continuum-restore 'on'

run '~/.tmux/plugins/tpm/tpm'

Start tmux with tmux new -A -s main and press prefix then capital I to fetch the plugins.

~/.ssh/config (each client)
Host devbox
  HostName devbox.example.ts.net
  User youruser
~/.zshrc or ~/.bashrc (each client)
alias dev='mosh devbox -- tmux new -A -s main'
Where it breaks

Seams

Where this meets the rest of the build. Each one leads with what you will actually see.

RemoteCommand meets mosh

Symptommosh can't start mosh-server

mosh launches its server over ssh, and a RemoteCommand in the host entry takes over that launch. Keep the host entry clean and put the tmux command in the alias.

A UDP-blocking network meets mosh

Symptommosh can't connect from a hotel or office network

mosh needs UDP 60000 to 61000. Where that's blocked, fall back to plain ssh: ssh -t devbox tmux new -A -s main, or Eternal Terminal for a TCP connection that also survives changes.

mosh meets scrollback

Symptomthe terminal won't scroll back

mosh keeps no scrollback of its own. Use tmux copy mode: prefix then [.

tmux meets tmux

Symptomkeys go to the wrong tmux

With tmux on your own machine too, reach the inner session with the prefix pressed twice. Or run tmux only on the server.

Verify

Checks
dev                 # lands in the main session

Then change networks (wifi to a phone hotspot) and the session carries on. Reboot the server, reconnect, and your windows come back.

Corrections and updates
  1. 17 Oct 2026First written.