prevent ssh session from freezing

in some linux distro they the ssh shell will freeze after not activity in interval second, i had change file `/etc/ssh/sshd_config` in server config to

ClientAliveInterval  1200
ClientAliveCountMax 3

but the shell still freeze after seconds no activity. no activity mean no sending packet from client to server, if this continue the server will hangup connection

to prevent this, in client side, we can sending null packet every periodic second, this will make connection between still alive

we can do this with 2 method,
if you are admin in client

edit file /etc/ssh/ssh_config and add or uncomment this line code

Host *
ServerAliveInterval 100

or second method you can create file config in ~/.ssh/config and fill with ServerAliveInterval 100 . this will send null packet every 100 second to server

echo "ServerAliveInterval 100" >> ~/.ssh/config


Leave a comment