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, a Ctrl-a prefix, longer historyCtrl-a instead of Ctrl-b, and 10,000 lines of scrollback.
~/.tmux.conf
set -g mouse on
set -g history-limit 10000

unbind C-b
set -g prefix C-a
bind C-a send-prefix

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'

# Keep this line at the very bottom
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.

Installed plugins meet a config that never loads them

Symptomyour windows don't come back after a reboot

Cloning the plugins into ~/.tmux/plugins isn't enough. Without the @plugin lines and the run line at the bottom of ~/.tmux.conf, tmux never loads them, so nothing is saved and nothing restores. Check with tmux show -g @continuum-restore, which should print on.

A quick reboot meets the 15-minute save

Symptomwindows come back after a reboot, but they're old ones

tmux-continuum saves every 15 minutes, and it restores the last save, not the session you were in. Reboot soon after opening windows and they're gone, or an older layout comes back. Save by hand first with prefix then Ctrl-s. ls -l ~/.local/share/tmux/resurrect/last shows when the last save happened. Restore runs when the tmux server starts, which is the first dev after boot; set -g @continuum-boot 'on' starts tmux at boot instead.

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. Save with prefix then Ctrl-s, reboot the server, run dev again, and your windows come back.

Corrections and updates
  1. 17 Oct 2026First written.
  2. 23 Oct 2026Matched to the box: a Ctrl-a prefix, 10,000 lines of history, no vi keys. Added the seam for plugins that are installed but never loaded.
  3. 23 Oct 2026Added the seam for the 15-minute save interval, found in the reboot test. Verify now saves by hand before rebooting.