Docs / Security / How to Configure SSH Idle Timeout

How to Configure SSH Idle Timeout

By Admin · Feb 25, 2026 · Updated Apr 24, 2026 · 436 views · 1 min read

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 2

This sends a keepalive every 300 seconds (5 min). After 2 missed responses (10 min total), the client is disconnected.

systemctl restart sshd

Client-Side

In ~/.ssh/config:

Host *\n    ServerAliveInterval 60\n    ServerAliveCountMax 3

Was this article helpful?