A key belonging to a departed engineer may be in `authorized_keys` on 300 servers. How do you rotate SSH keys across the fleet?
IntermediateScenarioNetworking, SSH and remote access
Answer
Situation read → Add new keys first, verify, then remove old ones, so nobody is locked out.
What I'd do →
- Generate new keys:
ssh-keygen -t ed25519 -C "ops-2026-11" -f ~/.ssh/ops_2026. - Push them with Ansible:
- ansible.posix.authorized_key:
user: ops
key: "{{ lookup('file', 'keys/ops_2026.pub') }}"
state: present
- Test login with the new key on every host (
ansible all -m ping --private-key ~/.ssh/ops_2026). - Remove old keys with
state: absent, or manage the whole file withexclusive: true. - Grep the fleet for unknown keys and investigate.
Why → Add-verify-remove avoids lockouts; exclusive makes the file match your source of truth.
Interview tip → End with "and this is why we moved to SSH certificates with short TTLs".
More on Networking, SSH and remote access
You need to reach a database on a private subnet from your laptop through a bastion. How?BeginnerYour security team wants SSH hardened on all servers. What changes do you make?BeginnerA new server needs a static IP, gateway and DNS on RHEL 9. How do you configure it persistently?BeginnerYou're changing the network config of a remote server over SSH and could lose access. How do you protect yourself?IntermediateA web server should accept HTTP/HTTPS from anywhere but SSH only from the office. Configure the firewall.BeginnerYour app servers need to reach the internet for updates but must not be reachable from it. How do you set it up on a Linux gateway?Intermediate