When you're connected to a remote server via SSH and running a long-running process (like Claude Code), your work is tied to that SSH connection. If the connection drops — due to network instability, laptop sleep, VPN hiccups, or anything else — the process terminates immediately.
This means:
- Any in-progress work is lost
- You have to start over
- Unreliable connections make remote work frustrating
tmux (terminal multiplexer) runs sessions on the server itself, independent of your SSH connection. When your connection drops, the tmux session keeps running. You simply reconnect and pick up where you left off.
Think of it like this:
- Without tmux: Your terminal is a window into the server. Close the window, the work stops.
- With tmux: Your terminal is a window into a persistent session on the server. Close the window, the session continues. Open a new window, you see the same session.
tmux only needs to be installed on the remote server (not your local machine).
sudo apt update && sudo apt install tmux# Create a named session
tmux new -s workOnce inside tmux, run your commands normally:
claudePress Ctrl+b then d to detach. The session keeps running.
# Reconnect via SSH first, then:
tmux attach -t work| Command | Description |
|---|---|
tmux ls |
List all sessions |
tmux attach -t <name> |
Attach to a session |
tmux kill-session -t <name> |
End a session |
1. SSH into server
2. tmux new -s claude
3. Run claude (or any long-running process)
4. [connection drops]
5. SSH back into server
6. tmux attach -t claude
7. Continue where you left off
Add this to ~/.tmux.conf on the server to keep more history:
set -g history-limit 50000