skip to content
Ruban Selvarajah

Dealing With Hung Terminal Sessions: SSH and kubectl

/ 2 min read

It sucks doesn’t it. You’ve got an active SSH session to your VM or a Bash session to your kubernetes pod. You step away for a bit to have some well-deserved coffee. But when you come back, it’s frozen.

The terminal’s unresponsive, leaving you stuck and frustrated.

Sure, there are ‘proper’ ways to configure your sessions to avoid this, but let’s be real: sometimes you just need a quick and dirty fix to get back in the game.

Let’s 🚀

Quick Fixes

SSH Sessions

If your SSH session has frozen and you can’t get any response, you don’t have to close the terminal and open a new one. You can just kill the session, freeing you up to start a new one.

Terminal window
# To kill a frozen SSH session
# Press Enter first, then type ~.

kubectl Sessions

If a kubectl command has frozen you can sort of do the same as well. But it’s important to note that this actually terminates all kubectl processes.

Terminal window
# To kill all kubectl processes
pkill -f kubectl

So there you have it, a couple of tricks to get you unstuck when your SSH or kubectl sessions freeze on you.

These aren't long-term solutions of course, but they'll get you through the day. And when you're finally frustrated enough to want a permanent fix, well, Google is your best friend 😉.