Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Is there a way to disconnect from an SSH session that has become unresponsive without killing the whole terminal? Specifically I'm using konsole, and the machine I'm working with sometimes hangs, but doesn't actually die (thus killing the connection). So SSH just hangs and I have to close the terminal and open a new one to try to ssh back into it or do anything else. Is there a way to effectively ctrl+c out of an ssh session?

share|improve this question
add comment

1 Answer 1

up vote 43 down vote accepted

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.

share|improve this answer
    
+1 this is what I do. –  Bill B Oct 9 '10 at 0:00
11  
Actually this will work regardless of what is happening on the remote machine. What you've experienced is that ~ is only active immediately after you've pressed Enter (otherwise it would be too intrusive). –  Gilles Oct 9 '10 at 0:04
2  
Perfect, I wish this was documented better somewhere, I've never seen to use this before –  Falmarri Oct 9 '10 at 0:18
1  
In (at least) Portuguese keyboards double tap ~ and then . –  rsilva Mar 11 '13 at 21:10
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.