Verify Group Ownership on SSH Server Private *_key Key Files
이 페이지는 아직 한국어로 제공되지 않습니다. 번역 작업 중입니다.
현재 번역 프로젝트에 대한 질문이나 피드백이 있으신 경우
언제든지 연락주시기 바랍니다.Description
SSH server private keys, files that match the /etc/ssh/*_key glob, must be
group-owned by ssh_keys group.
Rationale
If an unauthorized user obtains the private SSH host key file, the host could be impersonated.
Shell script
The following script can be run on the host to remediate the issue.
#!/bin/bash
# Remediation is applicable only in certain platforms
if rpm --quiet -q kernel-core; then
newgroup=""
if getent group "ssh_keys" >/dev/null 2>&1; then
newgroup="ssh_keys"
fi
if [[ -z "${newgroup}" ]]; then
>&2 echo "ssh_keys is not a defined group on the system"
else
find -P /etc/ssh/ -maxdepth 1 -type f ! -group ssh_keys -regextype posix-extended -regex '^.*_key$' -exec chgrp --no-dereference "$newgroup" {} \;
fi
else
>&2 echo 'Remediation is not applicable, nothing was done'
fi
Ansible playbook
The following playbook can be run with Ansible to remediate the issue.
- name: Gather the package facts
package_facts:
manager: auto
tags:
- CCE-86126-0
- NIST-800-171-03.01.02
- NIST-800-171-03.04.02
- configure_strategy
- file_groupownership_sshd_private_key
- low_complexity
- low_disruption
- medium_severity
- no_reboot_needed
- name: Check that the ssh_keys group is defined
ansible.builtin.getent:
database: group
key: ssh_keys
ignore_errors: true
when:
- '"kernel-core" in ansible_facts.packages'
- file_groupownership_sshd_private_key_newgroup is undefined
tags:
- CCE-86126-0
- NIST-800-171-03.01.02
- NIST-800-171-03.04.02
- configure_strategy
- file_groupownership_sshd_private_key
- low_complexity
- low_disruption
- medium_severity
- no_reboot_needed
- name: Set the file_groupownership_sshd_private_key_newgroup variable if ssh_keys
found
ansible.builtin.set_fact:
file_groupownership_sshd_private_key_newgroup: ssh_keys
when:
- '"kernel-core" in ansible_facts.packages'
- ansible_facts.getent_group["ssh_keys"] is defined
tags:
- CCE-86126-0
- NIST-800-171-03.01.02
- NIST-800-171-03.04.02
- configure_strategy
- file_groupownership_sshd_private_key
- low_complexity
- low_disruption
- medium_severity
- no_reboot_needed
- name: Find /etc/ssh/ file(s) matching ^.*_key$
ansible.builtin.command: find -P /etc/ssh/ -maxdepth 1 -type f ! -group ssh_keys
-regextype posix-extended -regex "^.*_key$"
register: files_found
changed_when: false
failed_when: false
check_mode: false
when: '"kernel-core" in ansible_facts.packages'
tags:
- CCE-86126-0
- NIST-800-171-03.01.02
- NIST-800-171-03.04.02
- configure_strategy
- file_groupownership_sshd_private_key
- low_complexity
- low_disruption
- medium_severity
- no_reboot_needed
- name: Ensure group owner on /etc/ssh/ file(s) matching ^.*_key$
ansible.builtin.file:
path: '{{ item }}'
follow: false
group: '{{ file_groupownership_sshd_private_key_newgroup }}'
state: file
with_items:
- '{{ files_found.stdout_lines }}'
when: '"kernel-core" in ansible_facts.packages'
tags:
- CCE-86126-0
- NIST-800-171-03.01.02
- NIST-800-171-03.04.02
- configure_strategy
- file_groupownership_sshd_private_key
- low_complexity
- low_disruption
- medium_severity
- no_reboot_needed
Warning
Remediation is not possible at bootable container build time because SSH host
keys are generated post-deployment.