Interview Prep/Ansible/Security and Secrets

How do you set up a secure automation user and SSH access?

BeginnerProductionSecurity and Secrets
Answer

A dedicated non-human account (for example ansible) per environment, with key-based SSH only, password login disabled, and the public key in authorized_keys. Use Ed25519 keys, one key per environment, stored in the CI/AWX credential store rather than on laptops.

- ansible.posix.authorized_key:
    user: ansible
    key: "{{ lookup('ansible.builtin.file', 'keys/ansible_prod.pub') }}"
    exclusive: true

exclusive: true removes any other keys on that account, so access is controlled entirely from Git. Combine with a restricted sudoers entry and logging of its use.

All Ansible questions Roadmap: Ansible

More on Security and Secrets