Issue: "Failed to connect to the host via ssh: Permission denied (publickey, password).\r\n"

Details of the Issue:

Yongbos-MacBook-Pro-2:yaml yongbotan$ ansible-playbook ping.yaml -vvv

ansible-playbook 2.5.5

config file = /etc/ansible/ansible.cfg

configured module search path = ['/Users/yongbotan/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']

ansible python module location = /anaconda3/lib/python3.6/site-packages/ansible

executable location = /anaconda3/bin/ansible-playbook

python version = 3.6.4 |Anaconda, Inc.| (default, Jan 16 2018, 12:04:33) [GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)]

Using /etc/ansible/ansible.cfg as config file

Parsed /etc/ansible/hosts inventory source with ini plugin

PLAYBOOK: ping.yaml **********************************************************************************************************************************************************************************************

1 plays in ping.yaml

PLAY [servers] ***************************************************************************************************************************************************************************************************

TASK [Gathering Facts] *******************************************************************************************************************************************************************************************

task path: /Users/yongbotan/Development/Ansible/yaml/ping.yaml:1

Using module file /anaconda3/lib/python3.6/site-packages/ansible/modules/system/setup.py

<10.160.78.97> ESTABLISH SSH CONNECTION FOR USER: yongbo

<10.160.78.97> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=yongbo -o ConnectTimeout=10 -o ControlPath=/Users/yongbotan/.ansible/cp/ce2d1b399f 10.160.78.97 '/bin/sh -c '"'"'echo ~yongbo && sleep 0'"'"''

<10.160.78.97> (255, b'', b'yongbo@10.160.78.97: Permission denied (publickey,password).\r\n')

fatal: [10.160.78.97]: UNREACHABLE! => {

"changed": false,

"msg": "Failed to connect to the host via ssh: yongbo@10.160.78.97: Permission denied (publickey,password).\r\n",

"unreachable": true

}

[WARNING]: Could not create retry file '/Users/yongbotan/Development/Ansible/yaml/ping.retry'. [Errno 13] Permission denied: '/Users/yongbotan/Development/Ansible/yaml/ping.retry'

Solution of the Issue:

Perform SSH login without password

3 Steps to Perform SSH login without password:

  • Step1: Create public and private keys using ssh-keygen on localhost:

  • Step2: Copy the public key to remote-host using ssh-copy-id

jsmith@local-host$ ssh-copy-id -i ~/.ssh/id_rsa.pub username@remote-host
  • Step3: Login to remote-host without entering the password

results matching ""

    No results matching ""