TMAegisBeta
Weitere Regeln für linux

Linux distributions

TMA-ALMA9-5.1.4

Ensure access to SSH public host key files is configured

MittelStufe 1Automatisiertlinux

Beschreibung

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.

So wird geprüft

Prüfmethode: Shell-Befehl

shell
alt0() { o=$(bash -c '#!/usr/bin/env bash
{
   l_ssh_group=""
   grep -Psiq -- '"'"'^\h*ID_LIKE="?([^#\n\r]+)?\bfedora\b'"'"' /etc/os-release 2>/dev/null && \
      grep -Psq -- '"'"'^ssh_keys\b'"'"' /etc/group 2>/dev/null && l_ssh_group="ssh_keys"
   while IFS= read -r l_key; do
      l_file="${l_key}.pub"
      ssh-keygen -lf "$l_file" &>/dev/null || continue
      while IFS=: read -r l_mode l_owner l_group; do
         if [ $(( l_mode & 0133 )) -gt 0 ] || [ "$l_owner" != "root" ] || \
            { [ "$l_group" != "$l_ssh_group" ] && [ "$l_group" != "root" ];
}; then
            printf '"'"'%s\n'"'"' "\"$l_file\": mode $l_mode owner $l_owner group $l_group"
         fi
      done < <(stat -Lc '"'"'%#a:%U:%G'"'"' "$l_file")
   done < <(sshd -T 2>/dev/null | awk '"'"'$1=="hostkey"{print $2}'"'"')
}' 2>&1); [ -z "$o" ] || { echo "step1: $o" | head -c 300; return 1; }; }; if alt0; then echo compliant; fi
Erwartete Ausgabe
compliant

So wird behoben

Behebungsmethode: Anleitung oder Infrastruktur-Patch

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}') }

Eigenschaften

Betriebssysteme
almalinux-9
Tags
cis-convertedlinux
Referenz
CIS AlmaLinux OS 9 Benchmark v3.0.0 - 5.1.4

Diesen Host prüfen

Führen Sie dies auf einem Rechner aus, den Sie prüfen dürfen. Der Scan ist schreibgeschützt.

shell
tmaegis scan --target linux