I was having an issue with my SSH sessions where, after a period of inactivity, they would freeze. They weren’t disconnecting or timing out; they were just frozen.
To solve this I made the following change. In /etc/ssh/ssh_config (works also for ~/.ssh/config for individual users), I added two lines to the “Host *” section:
Without going into a lot of detail, you can know that those are somewhat arbitrary – you can adjust those to your needs.
My entire “Host *” section looks like this (this is a RHEL system):
SendEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
SendEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
SendEnv LC_IDENTIFICATION LC_ALL LANGUAGE
Also, if you want to help out with connections TO your server, a similar directive in the main body of /etc/ssh/sshd_config will work:
Since this applies to the SSH server, don’t forget to restart the service with
service sshd restart
systemctl restart sshd.service