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.d/00-complianceascode-hardening.conf
:
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: Deduplicate values from /etc/ssh/sshd_config
lineinfile:
path: /etc/ssh/sshd_config
Remediation - Shell Script
# Remediation is applicable only in certain platforms
if [ ! -f /.dockerenv ] && [ ! -f /run/.containerenv ]; then
mkdir -p /etc/ssh/sshd_config.d
touch /etc/ssh/sshd_config.d/00-complianceascode-hardening.conf