Sometime ssh shell become unresponsive when left for too long. It is little annoying to close the terminal to kill the ssh session. To kill such session we can use escape sequence to terminate the connection. For the purpose of this article, we’ll use ssh session connected from Mac to Ubuntu Linux. Here is the sequence we can use:
[ENTER]~. (tilde dot after ENTER)
Note that escape sequence ~.
must follow an ENTER.
In case you want to see all possible escape sequences, you can enter the following escape sequence:
[ENTER]~?
Here is the outcome from the above help command:
Supported escape sequences: ~. - terminate connection (and any multiplexed sessions) ~B - send a BREAK to the remote system ~C - open a command line ~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.)