Imagine you're enjoying a really premium SSH session when the remote host's network drops out long enough to cause your client connection to hang, and things are past the point of recovery.
And, you'll soon remember, Ctrl+x is meaningless to SSH!
You have two paths at this point: run a web search for "SSH escape sequence", or just close the terminal emulator pane. No shame—I always pick the latter, too.
I scored a hanging session again about a day ago and virtuously chose the less trodden path and ended up on a Stack Overflow thread with the solution, typed sequentially:
[Enter] ~ . It seems a newline is the leading character sequence in SSH's escape narrative:
Supported escape sequences:
~. - terminate connection (and any multiplexed sessions)
~B - send a BREAK to the remote system
~R - request rekey
~V/v - decrease/increase verbosity (LogLevel)
~^Z - suspend ssh
~# - list forwarded connections
~& - background ssh (when waiting for connections to terminate)
~? - this message
~~ - send the escape character by typing it twice
(Note that escapes are only recognized immediately after newline.) Given how infrequently I need them, none of these sequences seem remotely memorable. Including the one that invokes the help message itself. But given SSH's role in capturing keyboard input, it's easily understandable why more familiar sequences—like those that lead with Ctrl—are not used.
And you know what? Maybe I don't need to remember the devil's sequence.
I use Ghostty as my terminal emulator and it now has a key binding statement in its configuration that soothes my inability to learn:
keybind = ctrl+x>s=text:\n~. Trigger
ctrl+x | Typed first |
> | Sequence marker |
s | Typed second |
Action
text | Declares Zig string literals follow |
\n~. | Our friend, [Enter] ~ . |
A quick test where I disabled Tailscale mid-session:
Last login: Wed Aug 26 20:12:41 2026 from fd7a:115c::495e
ennui ~ » ls -l /dev/disk/by-designator/
lrwxrwxrwx - root 21 Aug 19:44 esp -> ../../nvme0n1p4
ennui ~ »
ennui ~ »
ennui ~ » Connection to ennui closed. # Ctrl+x s typed here!
~ » Are computers fun again yet?