Ansible “Failed to connect to host via ssh: Permission denied” when trying -m ping all

ansibleansible-inventory

I've been at this all morning, and I've seen multiple posts about this error in other places, but none of the solutions seem to be working for me at this point.

I'm playing around with Ansible and trying to setup my inventory + hosts for this project.

For my hosts file I have (/etc/ansible/hosts):

[test-servers]

x.x.x.x

For my inventory I have (/etc/ansible/inventory.txt):

ansible-target ansible_ssh_host=x.x.x.x ansible_user=user ansible_ssh_pass=password

But when I try to run ansible -m ping all I get:

x.x.x.x | UNREACHABLE! => {
"changed": false,
"msg": Failed to connect to the host via ssh: user@x.x.x.x: Permission denied (publickey,password,keyboard-interacgive.\r\n"
"unreachable":true
}

However, I get a pong response successfully when I run:

ansible x.x.x.x -m ping -i /etc/ansible/inventory.txt

Anyone have any idea what this might be?

Thanks in advance.

Best Answer

Found the solution. Needed to have it prompt me for a password to setup the initial Ansible SSH configuration.

Ansible: Permission denied (publickey, password)

Related Topic