Solvedansible Failed to connect to the host via ssh: Permission denied (publickey,password)
✔️Accepted Answer
Good,
It's a bit hard to debug when you specify all
in your command.
Comment all lines in your hosts
file add this line
[webserver]
35.165.79.66 ansible_user=ubuntu
and try to run :
$: ansible webserver -m ping -vvv
And show me the output.
Regards
Other Answers:
Generate the ssh key on the master node:
root@master:~# ssh-keygen -t rsa -C "name@example.org"
Then copy your public key to the servers with ssh-copy-id:
root@master:~# ssh-copy-id user@child1.dev
root@master:~# ssh-copy-id user@child2.dev
I got this informations on this website https://valdhaus.co/writings/ansible-post-install/ and it is working
Hi,
I have found the solution.
If you are using ami(ubuntu 16) OS then there is no python installed, so you need to install it. Use below command to install python -
sudo apt-get install python-minimal -y
or
you need to use ami(ubuntu 14)OS. It has python 2.7.
Note : confirm which version of OS you have in your system.
I was getting the same problem:
$ ansible local -m ping
127.0.0.1 | UNREACHABLE! => {
"changed": false,
"msg": "Failed to connect to the host via ssh: Permission denied (publickey,password).\r\n",
"unreachable": true
}
Solved the issue by installing sshpass using command:
sudo apt-get install sshpass
After installng sshpass, I executed this command:
ansible local -m ping --ask-pass
SSH password:
127.0.0.1 | SUCCESS => {
"changed": false,
"ping": "pong"
}
```
Hope this helps!!!
Thanks.
From your output, I see that you don't have any ansible_user specified :
<35.165.79.66> ESTABLISH SSH CONNECTION FOR USER: None
Cat you show the content of your inventory file too ?
I have this error I use Debian Stretch and a guest manjaro in virtualbox.