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.
More on Security and Secrets
How do you give the automation user sudo with least privilege?IntermediateWhat are the alternatives to Ansible Vault for secrets, and when do you use them?IntermediateHow do you read AWS Secrets Manager and SSM parameters in a playbook?IntermediateHow do you integrate HashiCorp Vault with Ansible?AdvancedHow do you stop secrets from leaking into logs and output?BeginnerHow do you handle the vault password in CI/CD?Intermediate