How can I keep my SSH sessions from freezing CentOS 6

OpenSSH:

You need to enable


TCPKeepAlive yes

In your client ssh_config (e.g. /etc/ssh/ssh_config or in ~/.ssh/config) and your destination SSH server running OpenSSH (e.g. /etc/ssh/sshd_config).

So every time your connection idles, OpenSSH sends some dummy packet to your destination host

Login to the server and run this:

# nano /etc/ssh/sshd_config

Uncomment this line

#TCPKeepAlive yes

To

TCPKeepAlive yes

Then, restart ssh

On CentOS:

# service sshd restart
Stopping sshd:                                             [  OK  ]
Starting sshd:                                             [  OK  ]

Other Options:

IdleTimeout time

Sets idle timeout limit to time in seconds (s or nothing afternumber),
in minutes (m), in hours (h), in days (d), or in weeks (w).If the
connection have been idle (all channels) for that long time thechild
process is killed with SIGHUP, and connection is closed down.

ClientAliveInterval 60
TCPKeepAlive yes
ClientAliveCountMax 10000

ClientAliveInterval The server will wait 60 seconds before sending a null packet to the client to keep the connection alive

TCPKeepAlive Is there to ensure that certain firewalls don’t drop idle connections.

ClientAliveCountMax Server will send alive messages to the client even though it has not received any message back from the client.