Ramblings of an aging IT geek
← Ramblings of an aging IT geek
tooling

the dropped ssh connection that finally taught me tmux

Why a single tmux session per host means a flaky connection no longer kills a long-running job, plus the handful of settings that make it bearable.

A keyboard in front of a terminal session

I used to lose work to dropped SSH connections in the dumbest way: a long migration running in the foreground, the train goes through a tunnel, the connection dies, and the job dies with it. The fix is not a better connection. The fix is to stop tying the process to the connection at all.

tmux runs a session on the remote host that outlives your SSH link. You start work inside it, the connection drops, the session and everything in it keeps running on the server. You reconnect, type tmux attach, and you're exactly where you left off. That alone is the whole pitch and it's enough.

The settings that made it stick for me are few. I rebind the prefix from Ctrl-b to Ctrl-a because my fingers came from screen, turn the mouse on for lazy pane resizing, and crank the scrollback:

set -g prefix C-a
set -g mouse on
set -g history-limit 50000

That's most of it. There's a deep rabbit hole of plugins and status-bar fettling, and I've ignored almost all of it. The value isn't the configuration, it's the one habit: SSH in, attach the session, do the work inside it. Now a dropped connection is an inconvenience rather than a lost afternoon, and the tunnel can do its worst.