Interview Prep/Linux/Networking, SSH and remote access

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 →

  1. Generate new keys: ssh-keygen -t ed25519 -C "ops-2026-11" -f ~/.ssh/ops_2026.
  2. Push them with Ansible:
- ansible.posix.authorized_key:
    user: ops
    key: "{{ lookup('file', 'keys/ops_2026.pub') }}"
    state: present
  1. Test login with the new key on every host (ansible all -m ping --private-key ~/.ssh/ops_2026).
  2. Remove old keys with state: absent, or manage the whole file with exclusive: true.
  3. 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".

All Linux questions Roadmap: Linux

More on Networking, SSH and remote access