In general most of the ISP providers will terminate idle sessions as early as possible(maybe in a couple of minutes).
This will be an irritating thing if you work on a remote server with ssh. I had a similar issue with my ISP(Act Fibernet). To fix this issue I have experimented in multiple ways and I am sharing the easiest way to that works.
Add following lines in your /etc/ssh/sshd_config file:
ClientAliveInterval 60 ClientAliveCountMax 5
where ClientAliveInterval 60 seconds will send a null request from your node(client) to server every 60 seconds. ClientAliveCountMax 5 is to give up if it doesn’t receive any response after 5 retries.
After adding the above configurations restart ssh with the following command:
sudo service ssh restart
You can try with different values for ClientAliveInterval based on your ISP. In general most of the ISP’s will persist idle sessions for a couple of minutes. In my case Act Fibernet sessions are not responding after 2 minutes(approximately), so I used 60 seconds.