Automatically disconnect idle SSH sessions to reduce security risk.
Server-Side Configuration
Edit /etc/ssh/sshd_config:
# Disconnect after 10 minutes of inactivity\nClientAliveInterval 300\nClientAliveCountMax 2This sends a keepalive every 300 seconds (5 min). After 2 missed responses (10 min total), the client is disconnected.
systemctl restart sshdClient-Side
In ~/.ssh/config:
Host *\n ServerAliveInterval 60\n ServerAliveCountMax 3