Automating transfer of public keypair to a linux ssh remote server, bypassing password prompt in future use.
- Install Ansible and ansible.posix plugin in your local machine.
# sudo ansible-galaxy collection install ansible.posix - Configure a server (or a virtual server) and remember its ip address, username, and password.
- Create a ssh key pair.
# ssh-keygen - Change the <ip-addr-to-server>, <username>, <location-to-key> in files inventory and add_public keys.yaml accordingly.
- Run the scripts:
# ansible-playbook add_public_keys.yaml -k -K