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.
More on SSH & Access Hardening
What are the first sshd_config changes you make on a new production server?BeginnerWhy use a drop-in file in /etc/ssh/sshd_config.d/ instead of editing sshd_config?IntermediateWhy disable SSH password authentication entirely?BeginnerShould you change the SSH port from 22?IntermediateWhat are SSH certificates and why do large fleets use them?AdvancedHow do you restrict what a specific SSH key can do?Advanced