Verify Ownership on SSH Server Private *_key Key Files
An XCCDF Rule
Description
SSH server private keys, files that match the/etc/ssh/*_key
glob, must be owned
by root
user.
Rationale
If an unauthorized user obtains the private SSH host key file, the host could be impersonated.
- ID
- xccdf_org.ssgproject.content_rule_file_ownership_sshd_private_key
- Severity
- Medium
- Updated
Remediation Templates
A Shell Script
# Remediation is applicable only in certain platforms
if rpm --quiet -q kernel; then
find -L /etc/ssh/ -maxdepth 1 -type f ! -uid 0 -regextype posix-extended -regex '^.*_key$' -exec chown -L 0 {} \;
else
>&2 echo 'Remediation is not applicable, nothing was done'
fi
An Ansible Snippet
- name: Gather the package facts
package_facts:
manager: auto
tags:
- configure_strategy
- file_ownership_sshd_private_key