

In a playboook add a task with the copy module. Solution: copy the /.ssh/id_rsa.pub file to a /tmp location (as root/become_user) and then use authorized_keys to lookup in the /tmp folder.īelow adhoc commands to do the job. I'd appreciate if you let me know the solution.Īnsible authorized_key seems to not use the become_user, so does not have access to the. Error was a, original message: could not locate file in lookup: /home/zahr1/.ssh/id_rsa.pub" We need to enable PasswordAuthentication for this, as we.
#Ansible ssh copy id how to
In this post, we are going to see how to enable the SSH key-based authentication between two remote servers using ansible by creating and exchanging the keys. You need to add keys to this remote node using ssh-copy-id command (from workstation as shown below). This ensures that when the Ansible Automation Platform installation runs. "msg": "An unhandled exception occurred while running the lookup plugin 'file'. SSH Key based authentication setup using ansible. With the ansible user created, as the ansible user, copy the ssh key to all the nodes. : Unable to find '/home/zahr1/.ssh/id_rsa.pub' in expected paths (use -vvvvv to see paths) Does require Ansible 2.

Task path: /home/ansible/project1/setup-user.yaml:21 This will then allow for the task to run to copy the ssh key to the remote machine. Verify Password-Less SSH Access Step 3. For example: - name: ensure ssh-key is present : user: 'your-user' state: present key: 'your-public-key-goes-here'. We can copy these public key to /.ssh/authorizedkeys on the remote node manually (but the correct way is to use ssh-copy-id command.) 3. You want to use the authorizedkey module. I wanna create some local and remote users and generate ssh keypair for respective users and transfer them to remote server but it seems local user - ansible - which runs ansible-playbook does not have access to /home/USERNAME/.ssh/id_rsa.pub TASK *************************************************************************************************** Method 2: Manually add public key to /.ssh/authorizedkeys file.
