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.

This question already has an answer here:

When my SSH session times out, the whole terminal freezes.

Is there any way to break out of that connection? CTRL+C doesn't cut it.

share|improve this question

marked as duplicate by phunehehe, Anthon, slm, Gilles, Mat Jun 5 '13 at 13:40

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
What about Alt + SysReq + O? (Please note that I am only kidding!) –  Nathan Osman Jun 5 '13 at 5:36

2 Answers 2

You need to send the ssh escape sequence, which by default is ~ at the beginning of a line (in other words, preceded by a newline, or enter). Then send the disconnect character, which is ..

E.g.:

host1> ssh host2
Last login: Tue Jun  4 21:56:26 2013 from host1
host2>

(host2 freezes, press enter~.)

host2> Connection to host2 closed.
host1> 

See the ssh(1) manual:

-e escape_char
Sets the escape character for sessions with a pty (default: ‘~’). The escape character is only recognized at the beginning of a line. The escape character followed by a dot (‘.’) closes the connection; followed by control-Z suspends the connection; and followed by itself sends the escape character once. Setting the character to “none” disables any escapes and makes the session fully transparent.

share|improve this answer

You could kill the ssh process - ie, from another terminal using kill or killall.

... But Bahamat's way is the better, cleaner way.

share|improve this answer

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