How to kill an unresponsive ssh session

This is a Life saver! via http://www.laszlo.nu/post/553591402/how-to-kill-an-unresponsive-ssh-session

I often find myself in the somewhat cumbersome situation that a currently running ssh session stops responding, often due to a lost connection. The normal ctrl+c of course doesn’t work, the ssh client catches all the usual commands, which is very handy while you are still connected to the host but not very handy at all in this case.

My usual approach has been to switch to another terminal window or shell and then killing the process in question. Today I happened to be skimming through the ssh client’s man page and I found a section about escape characters. Suddenly I gazed upon the glory of the disconnect key sequence: a newline followed by ~.. It works like a charm. As always, I thought I should share.

And even more interesting suggestion in the comments:

Also interesting: You can press ~C and receive an ssh> prompt, where you can press ? for help. This prompt lets you enter additional -L or -R forwards you may have forgotten when starting the session. Very handy if you don’t want to log out and back in.

Advertisement

Tags: ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s


Follow

Get every new post delivered to your Inbox.