# Public Key works but not username password

**URL:** <https://forum.ansible.com/t/public-key-works-but-not-username-password/23441>\
**Category:** Ansible Project\
**Tags:** ubuntu\
**Created:** [January 12, 2017, 9:35am UTC](https://forum.ansible.com/t/public-key-works-but-not-username-password/23441 "2017-01-12T09:35:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Worked\_Whe](https://avatars.discourse-cdn.com/v4/letter/w/13edae/32.png) [@Worked\_Whe](https://forum.ansible.com/u/Worked_Whe)\
**Post date:** [January 12, 2017, 9:35am UTC](https://forum.ansible.com/t/public-key-works-but-not-username-password/23441/1 "2017-01-12T09:35:04Z")

</div>

My “Ansible Server” connect to remote “Host” as below.

Ansible Server —\> JumpServer → Host

I configured “Ansible Server” Appropriately for SSH Proxy. Now I can directly SSH to “Host” from “Ansible Server”, both with username/password and key.

When I copy public key of “Ansible Server” to “Host”, simple ping works fine with Ansible:

root@AnsibleServer:~/LogCollector# ansible 10.1.100.36 -i host\_inventory -u root -m ping  
10.1.100.36 | SUCCESS =\> {  
“changed”: false,  
“ping”: “pong”  
}

Then I remove public key from the “Host” and tried same with password.

root@AnsibleServer:~/LogCollector# ansible 10.1.100.36 -i host\_inventory -u root -m ping -k  
SSH password: xxxxxxx  
10.1.100.36 | UNREACHABLE! =\> {  
“changed”: false,  
“msg”: “Authentication failure.”,  
“unreachable”: true  
}

Any idea of what happens here.

Side Note:  
I installed Ansible 2.2 manually downloading all deb packages in my “Ansible Server” (Ubuntu 14.04) because of high security in my client and we don’t have internet access form the “Ansible Server”. I wonder the above problem is because of some missing library. Following are all the packages I had to install manually.

ansible\_2.2.0.0-1ppa~trusty\_all.deb  
libgmp10\_2%3a5.1.3+dfsg-1ubuntu1\_amd64.deb  
libyaml-0-2\_0.1.4-3ubuntu3.1\_amd64.deb  
python-crypto\_2.6.1-4build1\_amd64.deb  
python-httplib2\_0.8-2build1\_all.deb  
python-jinja2\_2.7.2-2\_all.deb  
python-markupsafe\_0.18-1build2\_amd64.deb  
python-paramiko\_1.10.1-1git1build1\_all.deb  
python-setuptools\_3.3-1ubuntu2\_all.deb  
python-yaml\_3.10-4ubuntu0.1\_amd64.deb  
sshpass\_1.05-1\_amd64.deb

Many thanks…!!

---

<div class="post-metadata">

**Author:** ![Johannes\_Kastl](https://avatars.discourse-cdn.com/v4/letter/j/bbe5ce/32.png) [@Johannes\_Kastl](https://forum.ansible.com/u/Johannes_Kastl)\
**Post date:** [January 13, 2017, 8:58am UTC](https://forum.ansible.com/t/public-key-works-but-not-username-password/23441/2 "2017-01-13T08:58:13Z")

</div>

You are logging in as root, check your sshd\_config for  
PermitRootLogin. I guess it is set to without-password, so logging in  
via ssh key works, password does not.

Try a non-root user, if my guess is right this should work with  
passwords...

Johannes
