Set SSH Client Alive Count Max to zero
An XCCDF Rule
Description
The SSH server sends at most ClientAliveCountMax
messages
during a SSH session and waits for a response from the SSH client.
The option ClientAliveInterval
configures timeout after
each ClientAliveCountMax
message. If the SSH server does not
receive a response from the client, then the connection is considered unresponsive
and terminated.
To ensure the SSH timeout occurs precisely when the
ClientAliveInterval
is set, set the ClientAliveCountMax
to
value of 0
in
/etc/ssh/sshd_config
:
Rationale
This ensures a user login will be terminated as soon as the ClientAliveInterval
is reached.
- ID
- xccdf_org.ssgproject.content_rule_sshd_set_keepalive_0
- Severity
- Medium
- References
- Updated
Remediation - Ansible
- name: Set SSH Client Alive Count Max to zero
block:
- name: Check for duplicate values
lineinfile:
path: /etc/ssh/sshd_config
Remediation - Shell Script
# Remediation is applicable only in certain platforms
if [ ! -f /.dockerenv ] && [ ! -f /run/.containerenv ]; then
if [ -e "/etc/ssh/sshd_config" ] ; then
LC_ALL=C sed -i "/^\s*ClientAliveCountMax\s\+/Id" "/etc/ssh/sshd_config"