Hi,
I am new for ansible. I wrote the following playbook to execute the ssh-copy-id to copy the id_rsa.pub key to remote host, but I am getting permission denied error or hanging when passing password as argument,
Playbook :
---
- name: Copy ssh key
hosts: Testing-Server
become: true
become_user: super_user
gather_facts: True
vars:
my_remotehost: "{{failedhost}}"
tasks:
- name: Copy ssh key to remote host
#command: "ssh-copy-id -i /super_user/.ssh/id_rsa.pub \"super_user@{{my_remotehost}}\""
#shell: "sshpass -p \"password\" ssh-copy-id -o PreferredAuthentications=password -o PasswordAuthentication=yes -o StrictHostKeyChecking=no -o PasswordAuthentication=yes -i /super_user/.ssh/id_rsa.pub \"super_user@{{my_remotehost}} \""
shell: "ssh-copy-id -o PreferredAuthentications=password -o PasswordAuthentication=yes -o StrictHostKeyChecking=no -o PasswordAuthentication=yes -i /super_user/.ssh/id_rsa.pub \"super_user@{{my_remotehost}} \""
#command: "ssh-copy-id -i /super_user/.ssh/id_rsa.pub \"super_user@{{my_remotehost}} \""
register: ssh_copy_id_execution
failed_when: ssh_copy_id_execution.rc != 0
- debug :
var: ssh_copy_id_execution.stdout_lines
I have configured the ansigle_ssh_user and ansible_ssh_pass in /etc/ansible/hosts file
I am executing the above playbook like as,
ansible-playbook ssh_copy_id_task.yml --ask-pass --ask-become-pass --extra-vars "failedhost=x.x.x.x" -vvvv
After the below lines in the output, it is hanging,
<x.x.x.x> ESTABLISH SSH CONNECTION FOR USER: root
<x.x.x.x> SSH: EXEC sshpass -d12 ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o User=root -o ConnectTimeout=10 -o ControlPath=/home/perl/.ansible/cp/07f7ed7577 -tt x.x.x.x '/bin/sh -c '"'"'/usr/bin/python /super_user/.ansible/tmp/ansible-tmp-1576576971.87-95887151849070/command.py && sleep 0'"'"''
Please help me to resolve this issue.