SSH Break?

Sometimes when using remote connections you will find that they hang up on you. When this happens you are left with a terminal that you can't use anymore. Mucho Pain in the Rear.

Now if you are using telnet, you can send a break sequence (^] or Ctrl+]) and then quit the connection. This means that you can fix it in the same terminal without having use another to kill it, far more productive.

So then I got to thinking, how do you do that with SSH? Initially I couldn't see a method but it turns out that the default of SSH is missing the critical configuration line to enable this sort of thing.

Simply edit either /etc/ssh/ssh_config or the local configuration file ~/.ssh/config and add the line:

EscapeChar ~

Then you can kill a hung SSH connection as well. When you are connected to a SSH shell, simply use this key sequence to quit the shell

<Enter> ~.

And bingo, the SSH connection will die!