# How to debug authentication failure

**URL:** <https://forum.ansible.com/t/how-to-debug-authentication-failure/11405>\
**Category:** Ansible Project\
**Created:** [April 12, 2012, 8:22pm UTC](https://forum.ansible.com/t/how-to-debug-authentication-failure/11405 "2012-04-12T20:22:31Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dan8](https://avatars.discourse-cdn.com/v4/letter/d/258eb7/32.png) [@Dan8](https://forum.ansible.com/u/Dan8)\
**Post date:** [April 12, 2012, 8:22pm UTC](https://forum.ansible.com/t/how-to-debug-authentication-failure/11405/1 "2012-04-12T20:22:31Z")

</div>

Debugging help?

ansible all -k -m ping  
SSH password:  
xsdsyb01 | FAILED =\> FAILED: Authentication failed.

However I can ssh easily to the server and the key is fine, see no  
password promt  
e93204@dhcp66238:~$ ssh xsdsyb01  
Last login: Thu Apr 12 15:12:07 2012 from dhcp66105.swaco

(-bash) e93204@xsdsyb01 ~\>

Also- when hosts contains loopback, everything seems to work...  
e93204@dhcp66238:~$ echo "127.0.0.1" \> ~/ansible\_hosts  
e93204@dhcp66238:~$ export ANSIBLE\_HOSTS=~/ansible\_hosts  
e93204@dhcp66238:~$ ansible all -m ping --ask-pass  
SSH password:  
127.0.0.1 | success \>\> {  
&nbsp;&nbsp;&nbsp;&nbsp;"ping": "pong"  
}

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [April 12, 2012, 8:26pm UTC](https://forum.ansible.com/t/how-to-debug-authentication-failure/11405/2 "2012-04-12T20:26:10Z")

</div>

If you don’t have a password prompt when logging in normally, you don’t have a need to use -k, and it will just use your keys.

-k (AKA --askpass) uses SSH by password.

-a and -s were taken, -k doesn’t stand for --key or anything like that 🙂

---

<div class="post-metadata">

**Author:** ![Seth\_Vidal](https://avatars.discourse-cdn.com/v4/letter/s/7ba0ec/32.png) [@Seth\_Vidal](https://forum.ansible.com/u/Seth_Vidal)\
**Post date:** [April 12, 2012, 8:36pm UTC](https://forum.ansible.com/t/how-to-debug-authentication-failure/11405/3 "2012-04-12T20:36:51Z")

</div>

> Debugging help?
> 
> ansible all -k -m ping  
> SSH password:  
> xsdsyb01 | FAILED =\> FAILED: Authentication failed.

^^^^ here you're logging in as root.

> However I can ssh easily to the server and the key is fine, see no  
> password promt  
> e93204@dhcp66238:~$ ssh xsdsyb01  
> Last login: Thu Apr 12 15:12:07 2012 from dhcp66105.swaco
> 
> (-bash) e93204@xsdsyb01 ~\>

^^^ here you're logging in as a user.

try:  
ssh root@xsdsyb01

and see what works or doesn't work.

> Also- when hosts contains loopback, everything seems to work...  
> e93204@dhcp66238:~$ echo "127.0.0.1" \> ~/ansible\_hosts  
> e93204@dhcp66238:~$ export ANSIBLE\_HOSTS=~/ansible\_hosts  
> e93204@dhcp66238:~$ ansible all -m ping --ask-pass  
> SSH password:  
> 127.0.0.1 | success \>\> {  
> &nbsp;&nbsp;&nbsp;&nbsp;"ping": "pong"  
> }

that's a special case for localhost/127.0.0.1 only - and I believe that  
is being added for explicit-request only, now.

Sfromm can comment on that

-sv

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [April 12, 2012, 8:39pm UTC](https://forum.ansible.com/t/how-to-debug-authentication-failure/11405/4 "2012-04-12T20:39:33Z")

</div>

Good catch Seth.

To clarify, the default login for /usr/bin/ansible is root unless you specify “-u username”.

In playbooks, this is simply “user: username” instead.

---

<div class="post-metadata">

**Author:** ![Stephen\_Fromm](https://avatars.discourse-cdn.com/v4/letter/s/bbce88/32.png) [@Stephen\_Fromm](https://forum.ansible.com/u/Stephen_Fromm)\
**Post date:** [April 12, 2012, 8:44pm UTC](https://forum.ansible.com/t/how-to-debug-authentication-failure/11405/5 "2012-04-12T20:44:49Z")

</div>

Seth’s correct. Right now, ansible will implicitly use LocalConnection for localhost. There are some patches queued up for review that change this to an explicit option. This will be true for the CLI and for playbooks.

sf

---

<div class="post-metadata">

**Author:** ![Dan8](https://avatars.discourse-cdn.com/v4/letter/d/258eb7/32.png) [@Dan8](https://forum.ansible.com/u/Dan8)\
**Post date:** [April 12, 2012, 11:35pm UTC](https://forum.ansible.com/t/how-to-debug-authentication-failure/11405/6 "2012-04-12T23:35:57Z")

</div>

That's exactly what I needed! Works now.

I misunderstood the "root permissions are not required to use it" on  
the gettingstarted page, which preceded literal examples.

Also I believe the line on that pge:  
&nbsp;&nbsp;&nbsp;&nbsp;cat "127.0.0.1" \> ~/ansible\_hosts  
might be clearer with  
&nbsp;&nbsp;&nbsp;&nbsp;echo "127.0.0.1" \> ~/ansible\_hosts

Thanks again,

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [April 12, 2012, 11:51pm UTC](https://forum.ansible.com/t/how-to-debug-authentication-failure/11405/7 "2012-04-12T23:51:58Z")

</div>

yeah I’m going to fix that one tonight, ticket’s open. Thanks!

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [June 15, 2012, 11:36am UTC](https://forum.ansible.com/t/how-to-debug-authentication-failure/11405/8 "2012-06-15T11:36:21Z")

</div>

Yeah, I’ll file a ticket on [https://github.com/ansible/ansible.github.com](https://github.com/ansible/ansible.github.com) so we don’t forget.
