fix-ssh-terminallisted
Install: claude install-skill MLliu6/lMl_skills
# fix-ssh-terminal
Diagnose and fix: **an idle SSH session dies, and afterwards the terminal spews
escape codes / mouse garbage.**
## Symptoms
- You leave a full-screen TUI (an AI coding CLI, `vim`, `htop`, a REPL, …) idle
over SSH. When you come back and touch it: `connection reset by peer`, and you
are dropped back to the machine you SSH'd from.
- After that, moving the mouse or clicking prints garbage like `[<0;80;24M` on
screen. Staying still is fine — only movement triggers it.
- You end up running `reset` and logging in again, losing whatever the TUI was
doing.
## Root cause
1. **The network cuts the idle connection.** An idle SSH connection is dropped by
an intermediate NAT/firewall; when you resume you receive a RST = "reset by
peer". (Default sshd `ClientAliveInterval` is `0`, so the *server* isn't cutting
it — the network is.)
2. **The TUI never restores the terminal.** A full-screen TUI puts the terminal
into raw mode + mouse reporting (DECSET 1000/1002/1003/1006). When the
connection is hard-killed (SIGHUP) it has no chance to restore → your local
terminal is still "reporting mouse", so any movement is sent as input and
printed as escape codes.
3. **It was not running inside `tmux`/`screen`.** A bare TUI dies with the
connection. If it were inside tmux, a drop would only *detach* it — the process
keeps running. This is the real fix.
## The 3-layer fix (most to least important)
### 1) Root fix — run the TUI inside tmux
A dr