Verify Group Ownership on SSH Server Public *.pub Key Files
An XCCDF Rule
Description
SSH server public keys, files that match the /etc/ssh/*.pub
glob, must be
group-owned by root
group.
Rationale
If a public host key file is modified by an unauthorized user, the SSH service may be compromised.
- ID
- xccdf_org.ssgproject.content_rule_file_groupownership_sshd_pub_key
- Severity
- Medium
- References
- Updated
Remediation - Shell Script
# Remediation is applicable only in certain platforms
if dpkg-query --show --showformat='${db:Status-Status}
' 'kernel' 2>/dev/null | grep -q installed; then
find -L /etc/ssh/ -maxdepth 1 -type f ! -group 0 -regextype posix-extended -regex '^.*\.pub$' -exec chgrp -L 0 {} \;
Remediation - Ansible
- name: Gather the package facts
package_facts:
manager: auto
tags:
- configure_strategy
- file_groupownership_sshd_pub_key