5.1.4 Ensure access to SSH public host key files is configured

Information

An SSH public key is one of two files used in SSH public key authentication. In this authentication method, a public key is a key that can be used for verifying digital signatures generated using a corresponding private key. Only a public key that corresponds to a private key will be able to authenticate successfully.

If a public host key file is modified by an unauthorized user, the SSH service may be compromised.

Solution

Run the following script to set the owner, group, and restrict permissions on each SSH public host key file from the running sshd configuration:

#!/usr/bin/env bash
{
while IFS= read -r l_key; do
l_file="${l_key}.pub"
[ -e "$l_file" ] || continue
chown root:root "$l_file"
chmod u-x,go-wx "$l_file"
done < <(sshd -T 2>/dev/null | awk '$1=="hostkey"{print $2}')
}

Impact:

Public host key files are intended to be readable; enforcing mode 0644, owner and group root, only removes excess write and execute permissions and does not affect normal SSH operation.

See Also

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

Item Details

Category: ACCESS CONTROL, CONFIGURATION MANAGEMENT, MEDIA PROTECTION

References: 800-53|AC-3, 800-53|AC-5, 800-53|AC-6, 800-53|CM-6b., 800-53|MP-2, CSCv7|14.6

Plugin: Unix

Control ID: d9ca8b9aea089208ed4651c7ac181d524318a4462740ac9f47ff9d101700af77