Recover locked terminal from dead SSH session
If you’ve ever been shelled into a server when your connection drops, you would have noticed that your terminal is completely locked up, you can’t even CTRL+C to get out of it. If you would like to save your terminal you can with the key sequence “<ENTER> ~ .”
SSH has a few more key strokes you can use too! To find out which ones are available type “<ENTER> ~?”
it’ll bring up this:
Supported escape sequences:
~. - terminate connection
~B - send a BREAK to the remote system
~C - open a command line
~R - Request rekey (SSH protocol 2 only)
~^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.)
Thanks to Herlo for this tip.








I can’t say how much this pisses me off. Thanks for the post.
Comment by Will Smith — September 29, 2007 @ 11:58 pm