Use the authorized_key Ansible module to copy the public ssh key (kept in the same folder as the Ansible project) and place it on the server in the . ssh/authorized_keys file. After this step it is possible to connect to the server using the ssh keys alone.
Ansible SSH Setup Playbook | #! code
www.hashbangcode.com > article > ansible-ssh-setup-playbook
Ansible relies on SSH for executing commands against remote Linux hosts. That means in order to leverage Ansible, you must configure this SSH access for the software such that you can overcome a password prompt automatically.
Ansible and SSH Considerations - Medium
medium.com > linux-academy > ansible-and-ssh-considerations-cc6a4299f...
Here are the commands we used:
1. all - Use all defined servers from the inventory file.
2. -m module - Use the "ping" module, which simply runs the ping command and returns the results.
3. -s - Use "sudo" to run the commands.
4. -u username - Log into servers using user username.
Ansible: SSH connection & running commands - 2020 - BogoToBogo www.bogotobogo.com > Ansible-SSH-Connection-Setup-Run-Command
Ansible communicates with remote machines over the SSH protocol. By default, Ansible uses native OpenSSH and connects to remote machines using your current user name, just as SSH does.
Getting Started - Ansible Documentation
docs.ansible.com > ansible > latest > user_guide > intro_getting_started