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: Gather the package facts
package_facts:
manager: auto
tags:
- CJIS-5.5.6
- NIST-800-171-3.1.11
Remediation - Shell Script
# Remediation is applicable only in certain platforms
if rpm --quiet -q kernel; then
# Find the include keyword, extract from the line the glob expression representing included files.
# And if it is a relative path prepend '/etc/ssh/'
included_files=$(grep -oP "^\s*(?i)include.*" /etc/ssh/sshd_config | sed -e 's/\s*include\s*//I' | sed -e 's|^[^/]|/etc/ssh/&|')