4.2.18 Ensure SSH MaxSessions is set to 10 or less

Information

The MaxSessions parameter specifies the maximum number of open sessions permitted from a given connection.

To protect a system from denial of service due to a large number of concurrent sessions, use the rate limiting function of MaxSessions to protect availability of sshd logins and prevent overwhelming the daemon.

Solution

Edit or create a file ending in *.conf in the /etc/ssh/sshd_config.d/ directory or the /etc/ssh/sshd_config file and set the MaxSessions parameter as follows:

MaxSessions 10

Run the following command to comment out any MaxSessions parameter entries in files ending in *.conf in the /etc/ssh/sshd_config.d/ directory or the /etc/ssh/sshd_config file that include any setting greater than 10

# grep -Pi '^s*MaxSessionss+(1[1-9]|[2-9][0-9]|[1-9][0-9][0-9]+)' /etc/ssh/sshd_config /etc/ssh/sshd_config.d/*.conf | while read -r l_out; do sed -ri "/^s*MaxSessionss+(1[1-9]|[2-9][0-9]|[1-9][0-9][0-9]+)/s/^/# /" "$(awk -F: '{print $1}' <<< $l_out)";done

See Also

https://workbench.cisecurity.org/benchmarks/12705

Item Details

Category: ACCESS CONTROL

References: 800-53|AC-10

Plugin: Unix

Control ID: cd0144fa673b131e854175930fb5b92c3e9d6b6aa264eade6df4143667ce0421