Showing posts with label ssh. Show all posts
Showing posts with label ssh. Show all posts

Wednesday, December 11, 2013

Prevent SSH connection from freezing

Recently I have experinced my ssh connection to remote server is hung after idle time. this is very annoying because ssh connection was established over vpn and take time to reconnect the session again. If your ssh connection hung/freeze time to time following solution may be helpful.


1) Open the ssh_config file.


location may differ,in centos
vim /etc/ssh/ssh_config

2) Add following lines


Host *
    ServerAliveInterval 300
    ServerAliveCountMax 2



Remember, this configuration is done at client side. client send keep alive message to server every 180 seconds and server send ack (acknowledgement) message.If 2 consecutive ack messages are lost from server side. connection will be dropped as server is not available.

Related Posts