Ansible Control Machine (ip = 1.1.1.1): NAME="Ubuntu"
VERSION="18.04.3 LTS (Bionic Beaver)" Target Node (ip = 2.2.2.2): NAME="Amazon Linux" VERSION="2" I am able to ssh from Ansible Control Machine to Target node if I manually type the SSH commands (Which means the keys from Ansible Control machine are properly copied to Target node already) [email protected]:~/ansible$ ssh [email protected] Last login: Mon Mar 16 02:13:42 2020 from ip-1.1.1.1.us-west-2.compute.internal __| __|_ ) _| ( / Amazon Linux 2 AMI ___|\___|___| https://aws.amazon.com/amazon-linux-2/ [[email protected] ~]$ But when I run the ansible command to ping target node, I get error: [email protected]:~/ansible$ ansible -i hosts -m ping all -vvv ansible 2.5.1 config file = /home/ubuntu/ansible/ansible.cfg configured module search path = [u'/home/ubuntu/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules'] ansible python module location = /usr/lib/python2.7/dist-packages/ansible executable location = /usr/bin/ansible python version = 2.7.17 (default, Nov 7 2019, 10:07:09) [GCC 7.4.0] Using /home/ubuntu/ansible/ansible.cfg as config file Parsed /home/ubuntu/ansible/hosts inventory source with ini plugin META: ran handlers Using module file /usr/lib/python2.7/dist-packages/ansible/modules/system/ping.py <1.1.1.1> ESTABLISH SSH CONNECTION FOR USER: ubuntu <1.1.1.1> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=ubuntu -o ConnectTimeout=10 -o ControlPath=/home/ubuntu/.ansible/cp/297a4ed557 1.1.1.1 '/bin/sh -c '"'"'echo ~ && sleep 0'"'"'' <1.1.1.1> (255, '', '[email protected]: Permission denied (publickey).\r\n') 1.1.1.1 | UNREACHABLE! => { "changed": false, "msg": "Failed to connect to the host via ssh: [email protected]: Permission denied (publickey).\r\n", "unreachable": true } "hosts" file [all] 2.2.2.2 "ansible.cfg: file [default] inventory = hosts ansible.cfg (END) Please suggest how to resolve the 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]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/c870fd20-33f4-438d-acc4-2e07e5616612%40googlegroups.com.
