documentation_complete: true

title: 'Set SSH Client Alive Count Max'

description: |-
    The SSH server sends at most <tt>ClientAliveCountMax</tt> messages
    during a SSH session and waits for a response from the SSH client.
    The option <tt>ClientAliveInterval</tt> configures timeout after
    each <tt>ClientAliveCountMax</tt> message. If the SSH server does not
    receive a response from the client, then the connection is considered unresponsive
    and terminated.
    For SSH earlier than v8.2, a <tt>ClientAliveCountMax</tt> value of <tt>0</tt>
    causes a timeout precisely when the <tt>ClientAliveInterval</tt> is set.
    Starting with v8.2, a value of <tt>0</tt> disables the timeout functionality
    completely. If the option is set to a number greater than <tt>0</tt>, then
    the session will be disconnected after
    <tt>ClientAliveInterval * ClientAliveCountMax</tt> seconds without receiving
    a keep alive message.

rationale: |-
    This ensures a user login will be terminated as soon as the <tt>ClientAliveInterval</tt>
    is reached.

severity: medium

identifiers:
    cce@rhcos4: CCE-82464-9
    cce@rhel8: CCE-80907-9
    cce@rhel9: CCE-90805-3
    cce@rhel10: CCE-86794-5
    cce@sle12: CCE-83034-9
    cce@sle15: CCE-91228-7
    cce@sle16: CCE-96453-6
    cce@slmicro5: CCE-93694-8
    cce@slmicro6: CCE-94685-5

references:
    cis-csc: 1,12,13,14,15,16,18,3,5,7,8
    cis@sle12: 5.2.16
    cis@sle15: 5.2.16
    cjis: 5.5.6
    cobit5: APO13.01,BAI03.01,BAI03.02,BAI03.03,DSS01.03,DSS03.05,DSS05.04,DSS05.05,DSS05.07,DSS05.10,DSS06.03,DSS06.10
    cui: 3.1.11
    hipaa: 164.308(a)(4)(i),164.308(b)(1),164.308(b)(3),164.310(b),164.312(e)(1),164.312(e)(2)(ii)
    isa-62443-2009: 4.3.3.2.2,4.3.3.5.1,4.3.3.5.2,4.3.3.6.1,4.3.3.6.2,4.3.3.6.3,4.3.3.6.4,4.3.3.6.5,4.3.3.6.6,4.3.3.6.7,4.3.3.6.8,4.3.3.6.9,4.3.3.7.2,4.3.3.7.3,4.3.3.7.4,4.3.4.3.3
    isa-62443-2013: 'SR 1.1,SR 1.10,SR 1.2,SR 1.3,SR 1.4,SR 1.5,SR 1.7,SR 1.8,SR 1.9,SR 2.1,SR 6.2'
    iso27001-2013: A.12.4.1,A.12.4.3,A.14.1.1,A.14.2.1,A.14.2.5,A.18.1.4,A.6.1.2,A.6.1.5,A.7.1.1,A.9.1.2,A.9.2.1,A.9.2.2,A.9.2.3,A.9.2.4,A.9.2.6,A.9.3.1,A.9.4.1,A.9.4.2,A.9.4.3,A.9.4.4,A.9.4.5
    nerc-cip: CIP-004-6 R2.2.3,CIP-007-3 R5.1,CIP-007-3 R5.2,CIP-007-3 R5.3.1,CIP-007-3 R5.3.2,CIP-007-3 R5.3.3
    nist: AC-2(5),AC-12,AC-17(a),SC-10,CM-6(a)
    nist-csf: DE.CM-1,DE.CM-3,PR.AC-1,PR.AC-4,PR.AC-6,PR.AC-7,PR.IP-2
    pcidss: Req-8.1.8
    srg: SRG-OS-000163-GPOS-00072,SRG-OS-000279-GPOS-00109
    stigid@ol8: OL08-00-010200
    stigid@sle12: SLES-12-030191
    stigid@sle15: SLES-15-010320

requires:
    - sshd_set_idle_timeout

ocil_clause: 'it is commented out or not configured properly'

ocil: |-
    To ensure <tt>ClientAliveInterval</tt> is set correctly, run the following command:
    <pre>$ sudo grep ClientAliveCountMax /etc/ssh/sshd_config</pre>
    If properly configured, the output should be:
    <pre>ClientAliveCountMax {{{ xccdf_value("var_sshd_set_keepalive") }}}</pre>
    For SSH earlier than v8.2, a <tt>ClientAliveCountMax</tt> value of <tt>0</tt> causes a timeout precisely when
    the <tt>ClientAliveInterval</tt> is set.  Starting with v8.2, a value of <tt>0</tt> disables the timeout
    functionality completely.
    If the option is set to a number greater than <tt>0</tt>, then the session will be disconnected after
    <tt>ClientAliveInterval * ClientAliveCountMax</tt> seconds without receiving a keep alive message.

template:
    name: sshd_lineinfile
    vars:
        parameter: ClientAliveCountMax
        xccdf_variable: var_sshd_set_keepalive
        datatype: int
