SSH is getting disconnected

I am in the middle of ‘Linux firewall setup’ task and whenever I attempt to do the task the terminal stops responding to my keyboard input all of a sudden. It’s happening every time I retry the task…

(My internet connection is stable and I have been retrying for 2 days, still the same issue is occurring)

The problem is that there is something (usually a firewall or load-balancer), which is dropping idle sessions. If you configure session keepalives, the keepalives will prevent network devices from considering the session as idle.

**Linux ** :
The simplest fix is to enable ssh client keepalives; this example will send an ssh keepalive every 60 seconds:

ssh -o "ServerAliveInterval 60" <SERVER_ADDRESS>

If you want to enable this on all your sessions, put this in your /etc/ssh/ssh_config or ~/.ssh/config :

ServerAliveInterval 60

1 Like

Thanks for sharing this, I will definitely try it the next time I reattempt the task. But I should clarify that I was typing the commands really fast and there was little chance of idle sessions.