Checks / Files

Sensitive files have loose permissions

Check
fs.sensitive_perms
Severity
high
Runs
on the server, in the daily run of the agent
Looks at
Mode and owner of /etc/shadow, /etc/gshadow, /etc/passwd, /etc/sudoers, sshd_config, SSH host keys
Updated 26 Nov 2026

What the check looks at

The agent compares the mode and owner of /etc/shadow, /etc/gshadow, /etc/passwd, /etc/sudoers, /etc/ssh/sshd_config and the private SSH host keys (/etc/ssh/ssh_host_*_key) with the values that are safe for each file. It reports the file, its mode and its owner, never the contents.

Why it matters

  • /etc/shadow and /etc/gshadow hold the password hashes. If other users can read them, they can try to crack the hashes offline.
  • /etc/passwd, /etc/sudoers and sshd_config decide who is root, who may use sudo and how SSH logs work. If a normal user can write to one of them, that user can make themselves root. sshd does not check the permissions of its configuration file.
  • A private host key that others can read lets them impersonate the server. sshd itself refuses such a key: it prints Permissions 0644 for '/etc/ssh/ssh_host_ed25519_key' are too open. and This private key will be ignored.

Loose permissions usually come from a chmod -R or a cp without -p during a migration or a restore from backup.

How to fix it

The defaults we found on fresh installations (November 2026):

File Debian, Ubuntu RHEL, Rocky Linux, AlmaLinux Alpine
/etc/shadow 640 root:shadow 000 root:root 640 root:shadow
/etc/gshadow 640 root:shadow 000 root:root (does not exist)
/etc/passwd 644 root:root 644 root:root 644 root:root
/etc/sudoers 440 root:root 440 root:root 440 root:root
/etc/ssh/sshd_config 644 root:root 600 root:root 644 root:root
private host keys 600 root:root 600 root:root (Rocky Linux 9 key generation: 640 root:ssh_keys) 600 root:root

Debian and Ubuntu

sudo chown root:shadow /etc/shadow /etc/gshadow && sudo chmod 640 /etc/shadow /etc/gshadow
sudo chown root:root /etc/passwd /etc/sudoers /etc/ssh/sshd_config
sudo chmod 644 /etc/passwd /etc/ssh/sshd_config
sudo chmod 440 /etc/sudoers
sudo chmod 600 /etc/ssh/ssh_host_*_key

RHEL, Rocky Linux and AlmaLinux

The package setup owns the account files, so rpm can put them back:

sudo rpm -V setup               # lists files whose mode or owner changed (M, U, G)
sudo rpm --restore setup        # restores mode and owner of shadow, gshadow, passwd, group
sudo chmod 440 /etc/sudoers
sudo chmod 600 /etc/ssh/sshd_config /etc/ssh/ssh_host_*_key

Alpine

chown root:shadow /etc/shadow && chmod 640 /etc/shadow
chown root:root /etc/passwd /etc/sudoers /etc/ssh/sshd_config
chmod 644 /etc/passwd /etc/ssh/sshd_config
chmod 440 /etc/sudoers
chmod 600 /etc/ssh/ssh_host_*_key

If a private host key was readable by others for a while, generate new host keys (ssh-keygen -A after moving the old ones away) and update the known_hosts entries of the clients.

How to check the fix

sudo stat -c '%a %U:%G %n' /etc/shadow /etc/gshadow /etc/passwd /etc/sudoers \
    /etc/ssh/sshd_config /etc/ssh/ssh_host_*_key
sudo sshd -t

The modes must match the table, and sshd -t must not print UNPROTECTED PRIVATE KEY FILE.

When a warning is fine

Stricter modes than the table are fine (for example 600 for sshd_config on Debian). Group ssh_keys with mode 640 on RHEL-family host keys is the layout of the RHEL key generation and is fine as well.

Sources