On 12/17/19 1:10 PM, Ganeshwari Sk wrote:
> 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,

1. Make sure that Ansible is able to connect via SSH.

2. Use authorized_keys module.

Regards
        Racke

> 
> 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.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to
> [email protected] 
> <mailto:[email protected]>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/9cbcd41f-ca35-49bc-9520-03af80b91ba7%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/9cbcd41f-ca35-49bc-9520-03af80b91ba7%40googlegroups.com?utm_medium=email&utm_source=footer>.


-- 
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration. Provisioning with Ansible.

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/1f95d5fb-0e8c-aebf-fcf1-a2411ec05f95%40linuxia.de.

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to