Close stuck SSH sessions

Something I’ve been looking for as long as I’ve been using SSH is a way to force the SSH client to exit. When dealing with unreliable connections or working with embedded Linux devices, you can often end up with a SSH client that thinks it’s still logged in, and which insists on sending all keystrokes blindly into the aether until the connection finally times out.

There is a way out that doesn’t require opening another terminal to kill the SSH client: press enter, tilde (~), and then period (.), typing each as a separate keystroke. This doesn’t appear to be a well-known feature (perhaps it’s just my poor luck in looking for it), but can be quite a time saver.

3 comments

  1. Gevious says:

    Thats brilliant. I’ve often wondered how to break out of a dead ssh session. What an obscure way to do it. Thanks for the answer

  2. lfz says:

    What the math??!! It really does work, I wonder what’s the reasoning behind this choice of method to close the stuck sessions.

  3. Gonzalo Cao says:

    That was incredibly cool! So usefull! Looking how to close an ssh connection from another one I’ve find this simple-but-effective method.

    Thanks a lot!

Leave a Reply

Your email address will not be published. Required fields are marked *

*