putty is closing the session after some time if it is idle.
There is no
time parameter on putty, so how can I keep my
putty ssh session always Alive?
Another thing to check is if your system is setting the environment variable TMOUT. To check this you can just do:
env | grep TMOUT
If it is set, you could change it or unset it. To change the value:
Where the number is the number of seconds until you get logged out. Otherwise unset it to turn off the feature:
Note, it may be that your system administrator has set this for security reasons. So if you are not the system administrator you may want to check this before changing anything yourself.
Enable SSH keep-alives by changing the following setting to a positive value:
A value of 300 should suffice in most cases. (5 minutes.) This causes PuTTY to send SSH null packets to the remote host periodically, so that the session doesn't time out.
Note that we don't want the
SO_KEEPALIVE option lower on that page. That is a much lower-level mechanism which is best used only when the application-level protocol doesn't have its own keepalive mechanism. SSH does, so we shouldn't use TCP keepalives in this case.
There are other things that can cause connections to drop, but this is a solid first thing to try. If it doesn't work, you'd need to look into these other things: VPN timeouts, router timeouts, settings changes on the remote SSH server, flaky connections, etc.
In addition to the other answers, I'd suggest running
screen to be able to have session management even if putty does terminate (connection dying, vpn going down, etc.).
Just run this on your putty this make sure, to activate your session for every 10-mins.
while true; do date; sleep 600; done
If none of the above didn't help,
You have to change your system sshd configs!
NOTE THAT, YOU WILL NEED ROOT PERMISSIONS FOR THIS!
in my case it was located
ClientAliveInterval 300 ClientAliveCountMax 0
ClientAliveInterval 6000 ClientAliveCountMax 3
service sshd restart
You can use the
top command in the shell prompt. This will keep your session alive.
Connection>SSH menu, use the following value as
bash --rcfile <(echo 'source ~/.bash_profile; unset TMOUT').