Can I unfreeze bash or vim when SSH session freezes from timeout?

10,447

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:
10,447
d-_-b
Author by

d-_-b

(your about me is currently blank)

Updated on September 18, 2022

Comments

  • d-_-b
    d-_-b almost 2 years

    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.

  • casey
    casey about 6 years
    This answer is amazing