How to kill a hung SSH session

It can happen for a number of reasons. You’re connected to a server via SSH and
things just stop responding. It’s hung, stuck, frozen, locked up, unresponsive
or many just not be paying attention to the keys you’re so desperately pounding
on your keyboard.

It’s happens regularly, but not regularly enough that I end up remembering how
to remedy the situation. Sure you could just close the terminal tab or window,
but that’s not very elegant.

Fortunately there’s a quick couple of key strokes you can make to take care of
things for you.

Next time you have an SSH session that’s hung up, just tap ~ and then ..

That’s it!

Upon entering this magical sequence of keys, you should be greeted with a
Connection to x.x.x.x closed. and are dropped back to your system’s command
prompt.

I’m not sure the circumstances, but sometimes I have to hit the keys a few times
before it will take, so I usually slam the Enter key a few times before just
out of rage.

Hopefully documenting this will help me remember this sequence better!

Josh Sherman - The Man, The Myth, The Avatar

About Josh

Husband. Father. Pug dad. Musician. Founder of Holiday API, Head of Engineering and Emoji Specialist at Mailshake, and author of the best damn Lorem Ipsum Library for PHP.


If you found this article helpful, please consider buying me a coffee.