TMAegisBeta
Mais regras para linux

Linux distributions

TMA-ALINUX2-5.2.3

Ensure permissions on SSH private host key files are configured

MédiaNível 1Automatizadalinux

Descrição

An SSH private key is one of two files used in SSH public key authentication. In this authentication method, The possession of the private key is proof of identity. Only a private key that corresponds to a public key will be able to authenticate successfully. The private keys need to be stored and handled carefully, and no copies of the private key should be distributed.

Como é verificado

Método de auditoria: Comando shell

shell
alt0() { o=$(bash -c 'find /etc/ssh -xdev -type f -name '"'"'ssh_host_*_key'"'"' -exec stat {} \;' 2>&1); printf '%s\n' "$o" | tr -s ' \t' '  ' | sed 's/^ //;s/ $//' | grep -Fxq -- 'File: ‘/etc/ssh/ssh_host_rsa_key’' || { echo step1: missing 'File: ‘/etc/ssh/ssh_host_rsa_key’'; return 1; }; printf '%s\n' "$o" | tr -s ' \t' '  ' | sed 's/^ //;s/ $//' | grep -Fxq -- 'Size: 1679 Blocks: 8 IO Block: 4096 regular file' || { echo step1: missing 'Size: 1679 Blocks: 8 IO Block: 4096 regular file'; return 1; }; printf '%s\n' "$o" | tr -s ' \t' '  ' | sed 's/^ //;s/ $//' | grep -Fxq -- 'Device: ca01h/51713d Inode: 8628138 Links: 1' || { echo step1: missing 'Device: ca01h/51713d Inode: 8628138 Links: 1'; return 1; }; printf '%s\n' "$o" | tr -s ' \t' '  ' | sed 's/^ //;s/ $//' | grep -Fxq -- 'Access: (0640/-rw-r-----) Uid: ( 0/ root) Gid: ( 998/ssh_keys)' || { echo step1: missing 'Access: (0640/-rw-r-----) Uid: ( 0/ root) Gid: ( 998/ssh_key'; return 1; }; printf '%s\n' "$o" | tr -s ' \t' '  ' | sed 's/^ //;s/ $//' | grep -Fxq -- 'Access: 2018-10-22 18:24:56.861750616 +0000' || { echo step1: missing 'Access: 2018-10-22 18:24:56.861750616 +0000'; return 1; }; printf '%s\n' "$o" | tr -s ' \t' '  ' | sed 's/^ //;s/ $//' | grep -Fxq -- 'Modify: 2018-10-22 18:24:56.861750616 +0000' || { echo step1: missing 'Modify: 2018-10-22 18:24:56.861750616 +0000'; return 1; }; printf '%s\n' "$o" | tr -s ' \t' '  ' | sed 's/^ //;s/ $//' | grep -Fxq -- 'Change: 2018-10-22 18:24:56.873750616 +0000' || { echo step1: missing 'Change: 2018-10-22 18:24:56.873750616 +0000'; return 1; }; printf '%s\n' "$o" | tr -s ' \t' '  ' | sed 's/^ //;s/ $//' | grep -Fxq -- 'Birth: -' || { echo step1: missing 'Birth: -'; return 1; }; printf '%s\n' "$o" | tr -s ' \t' '  ' | sed 's/^ //;s/ $//' | grep -Fxq -- 'File: ‘/etc/ssh/ssh_host_ecdsa_key’' || { echo step1: missing 'File: ‘/etc/ssh/ssh_host_ecdsa_key’'; return 1; }; printf '%s\n' "$o" | tr -s ' \t' '  ' | sed 's/^ //;s/ $//' | grep -Fxq -- 'Size: 227 Blocks: 8 IO Block: 4096 regular file' || { echo step1: missing 'Size: 227 Blocks: 8 IO Block: 4096 regular file'; return 1; }; printf '%s\n' "$o" | tr -s ' \t' '  ' | sed 's/^ //;s/ $//' | grep -Fxq -- 'Device: ca01h/51713d Inode: 8631760 Links: 1' || { echo step1: missing 'Device: ca01h/51713d Inode: 8631760 Links: 1'; return 1; }; printf '%s\n' "$o" | tr -s ' \t' '  ' | sed 's/^ //;s/ $//' | grep -Fxq -- 'Access: (0640/-rw-r-----) Uid: ( 0/ root) Gid: ( 998/ssh_keys)' || { echo step1: missing 'Access: (0640/-rw-r-----) Uid: ( 0/ root) Gid: ( 998/ssh_key'; return 1; }; printf '%s\n' "$o" | tr -s ' \t' '  ' | sed 's/^ //;s/ $//' | grep -Fxq -- 'Access: 2018-10-22 18:24:56.897750616 +0000' || { echo step1: missing 'Access: 2018-10-22 18:24:56.897750616 +0000'; return 1; }; printf '%s\n' "$o" | tr -s ' \t' '  ' | sed 's/^ //;s/ $//' | grep -Fxq -- 'Modify: 2018-10-22 18:24:56.897750616 +0000' || { echo step1: missing 'Modify: 2018-10-22 18:24:56.897750616 +0000'; return 1; }; printf '%s\n' "$o" | tr -s ' \t' '  ' | sed 's/^ //;s/ $//' | grep -Fxq -- 'Change: 2018-10-22 18:24:56.905750616 +0000' || { echo step1: missing 'Change: 2018-10-22 18:24:56.905750616 +0000'; return 1; }; printf '%s\n' "$o" | tr -s ' \t' '  ' | sed 's/^ //;s/ $//' | grep -Fxq -- 'Birth: -' || { echo step1: missing 'Birth: -'; return 1; }; printf '%s\n' "$o" | tr -s ' \t' '  ' | sed 's/^ //;s/ $//' | grep -Fxq -- 'File: ‘/etc/ssh/ssh_host_ed25519_key’' || { echo step1: missing 'File: ‘/etc/ssh/ssh_host_ed25519_key’'; return 1; }; printf '%s\n' "$o" | tr -s ' \t' '  ' | sed 's/^ //;s/ $//' | grep -Fxq -- 'Size: 387 Blocks: 8 IO Block: 4096 regular file' || { echo step1: missing 'Size: 387 Blocks: 8 IO Block: 4096 regular file'; return 1; }; printf '%s\n' "$o" | tr -s ' \t' '  ' | sed 's/^ //;s/ $//' | grep -Fxq -- 'Device: ca01h/51713d Inode: 8631762 Links: 1' || { echo step1: missing 'Device: ca01h/51713d Inode: 8631762 Links: 1'; return 1; }; printf '%s\n' "$o" | tr -s ' \t' '  ' | sed 's/^ //;s/ $//' | grep -Fxq -- 'Access: (0600/-rw-------) Uid: ( 0/ root) Gid: ( 998/ssh_keys)' || { echo step1: missing 'Access: (0600/-rw-------) Uid: ( 0/ root) Gid: ( 998/ssh_key'; return 1; }; }; if alt0; then echo compliant; fi
Saída esperada
compliant

Como é corrigido

Método de correção: Orientação ou patch de infraestrutura

Run the following commands to set ownership and permissions on the private SSH host key files # find /etc/ssh -xdev -type f -name 'ssh_host_*_key' -exec chown root:ssh_keys {} \; # find /etc/ssh -xdev -type f -name 'ssh_host_*_key' -exec chmod 0640 {} \;

Propriedades

Sistemas operacionais
alinux-2
Tags
cis-convertedlinux
Referência
CIS Aliyun Linux 2 Benchmark v1.0.0 ARCHIVE - 5.2.3

Verificar este host

Execute isto em uma máquina que você tenha permissão para auditar. A varredura é somente leitura.

shell
tmaegis scan --target linux