← ClaudeAtlas

fix-ssh-terminallisted

Diagnose and fix the "an idle SSH session dies and afterwards the terminal spews escape codes / mouse garbage" failure. Symptoms: you leave a full-screen TUI (an AI coding CLI, vim, htop, a REPL, ...) idle over SSH; when you return and touch it you get "connection reset by peer" and are dropped back to the machine you SSH'd from; afterwards moving the mouse or clicking prints garbage like [<0;80;24M (staying still is fine, only movement triggers it), and you must run reset and log in again. Root cause: the idle SSH connection is torn down by the network while a TUI holds the terminal in raw + mouse-reporting mode, and it is not running inside tmux/screen, so it is killed before it can restore the terminal. Trigger this skill when the user mentions SSH disconnect, connection reset by peer, dropped/idle SSH, needing reset after being idle, mouse codes / escape codes / garbage on screen, or wanting a long-running TUI to survive disconnects. Chinese triggers: SSH 掉线, peer reset, 连接被重置, 终端乱码, 光标移动出现字母数字码, 空闲掉线, 希望
MLliu6/lMl_skills · ★ 0 · AI & Automation · score 67
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