Kill Unresponsive remote SSH Sessions

ssh-escape-cha_2013-07-31_19-11-17

I spend a lot of time working with ssh terminals over very slow connections. One common  issue that crops up often  is unresponsive terminals. Closing the terminal is what most of us would go with but then you would have to go through the login workflow again.  If you had to login to 3 servers then redoing that every time would be a pain.

Here’s a quick tip. The next time your ssh session becomes unresponsive, hit “ENTER” , followed the  “~” key and finally the  “.” key. ( ENTER , ~ , . ) . That will terminate the unresponsive session but still keep you within your main ssh session.

SSH supports a bunch of escape characters. It’s a less known feature but in my case proved handy. To see a list of all the supported escape characters run ” ENTER , ~ , ? “.

[root@server conf.d]# ~?
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 (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.)

© 2008-2012 The Danesh Project
Powered by Wordpress and made by Guerrilla. Hosted at ServerFreak