Interview Prep/Linux/SSH & Access Hardening

How do you detect unauthorized SSH keys across a fleet?

AdvancedProductionSSH & Access Hardening
Answer

Manage authorized_keys only through config management (Ansible authorized_key with exclusive: true) or move to SSH certificates or AuthorizedKeysCommand that fetches keys from a central directory. Then periodically audit:

sudo find / -xdev -name authorized_keys -o -name authorized_keys2 2>/dev/null \
  | xargs -r sudo ssh-keygen -lf

Compare fingerprints with the approved list and alert on drift. Watch the files with auditd too.

All Linux questions Roadmap: Linux

More on SSH & Access Hardening