Interview Prep/Ansible/Security: Vault, Become and Compliance

How do you disable root SSH login and password authentication across the fleet safely?

IntermediateScenarioSecurity: Vault, Become and Compliance
Answer

Situation read → High-risk hardening change.

What I'd do →

  1. Confirm key-based sudo access works for the Ansible user on a canary.
  2. Apply with validate and a reload handler.
  3. Open a second SSH session before the change.
  4. Roll with serial.
- ansible.builtin.copy:
    dest: /etc/ssh/sshd_config.d/10-hardening.conf
    content: |
      PermitRootLogin no
      PasswordAuthentication no
    mode: "0600"
    validate: /usr/sbin/sshd -t -f %s
  notify: Reload sshd

Why → A mistake here removes your own access.

Interview tip → Note that validate with a drop-in file only validates syntax of the fragment; test the full config when possible.

All Ansible questions Roadmap: Ansible

More on Security: Vault, Become and Compliance