Kill an unresponsive ssh session without closing the terminal
One way is to use the ssh escape character. By default this is "~", but it can be set manually with -e
option when invoking ssh or via EscapeChar
in your ssh config. To kill the hung session this will often work:
~.
As pointed out by Gilles this is only recognized immediately after hitting Enter.
Sorry to repost accepted answer. Just to clarify it, Hope it help newcomer.
Press Enter
Press shift~
Press .
Cursor will get back to local prompt.