What are the best practices to be followed wrt security when it comes to SSH authentication (password less, key based, etc.) when setting up Ansible in a new environment with 1000s of machines? Which is the best method of using passwordless SSH in an enterprise environment and why?
The answer is
Key Based SSH
- You can SSH multiple host machines using the same key or Different keys.
- If you reboot your machine while playbook running it again SSH using your provided key so your ansible-playbook runs without occurring any errors.
- Also, you get authentication using the appropriate user.
use can use inventory.ini file
[hostMachine] [email protected] ansible_ssh_user=ubuntu ansible_ssh_private_key_file=/path of your pem file [ABCDMachine] [email protected] ansible_ssh_user=ABCD ansible_ssh_private_key_file=/path of your pem file
Command for run ansible-playbook
ansible-playbook -i inventory.ini main.yml