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 →
- Confirm key-based sudo access works for the Ansible user on a canary.
- Apply with
validateand areloadhandler. - Open a second SSH session before the change.
- 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.
More on Security: Vault, Become and Compliance
Database passwords are sitting in plain text in `group_vars`. How do you fix it?BeginnerYou need separate vault passwords for staging and prod.IntermediateHow do you change the vault password for all encrypted files?IntermediateA CI pipeline needs the vault password without storing it in the repo.IntermediateYou want to see the value inside an encrypted file without writing a decrypted copy to disk.BeginnerOnly one value in a vars file is secret and you want it in the same file as plain values.Beginner