Killing stale SSH connections | linux centos bash stale ssh connections script ClientAliveInterval

I administer a large scale SSH server with upwards of 300+ concurrent sessions. This server presents some challenges.  When migrated to AWS it started experiencing a large number of stale SSH sessions.

Fixing this was achieved in two parts. First was a bash script which ran every hour which culled all the stale connections.

The second part was to specify keepalive packets at 5 second intervals in the /etc/ssh/sshd_config file.

 

Leave a Reply

Your email address will not be published. Required fields are marked *