Linux distributions
TMA-ALINUX2-5.2.3
Ensure permissions on SSH private host key files are configured
中レベル 1自動linux
説明
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.
チェック方法
監査方法: シェルコマンド
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- 期待される出力
compliant
修正方法
修正方法: ガイダンスまたは IaC パッチ
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 {} \;
プロパティ
- オペレーティングシステム
- alinux-2
- タグ
- cis-convertedlinux
- 参照
- CIS Aliyun Linux 2 Benchmark v1.0.0 ARCHIVE - 5.2.3
このホストをチェック
監査が許可されているマシンで実行してください。スキャンは読み取り専用です。
shell
tmaegis scan --target linux