why do my ssh sessions freeze after some time? [closed]

Apologies if this is not the right place for asking this question.

I regularly need to ssh to different servers. Now, from my home machine (linux mint), when I connect via ssh, after some time of inactivity, my ssh shell freezes, and there's no way to get it back. The only thing I can do is '~.", that at least gives me my initiating shell back.

When I login from other locations to the same servers there's no issue. Could that be a problem with my ISP? How can I investigate further on this one?

It's really annoying, as I have to re-establish ssh connections after the freeze, navigate back to where I was and resume work. Thanks


Solution 1:

Your NAT is dropping your TCP socket after a period of inactivity.

Your ssh client can optionally send periodic noops to the server, thereby eliminating this problem. To do this, add this to your ~/.ssh/config:

Host *
  ServerAliveInterval 60

Alternatively, re-configure your NAT to not expire items out of its state table as quickly as it is now.


In addition to the above, you should be using a terminal multiplexer for your sessions - something like GNU Screen or tmux. With either of those, you can recover your session in the event of getting disconnected.