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.

Rationale:

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

Default Value:

MaxSessions 10

See Also

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

Item Details

Category: ACCESS CONTROL

References: 800-53|AC-10

Plugin: Unix

Control ID: bbed569eed87115d6fb0355977a422e05de72e78638bf0c7f42112c5bbcd117f