# Using ansbile and ansbile-playbook with just the password for the remote host

**URL:** <https://forum.ansible.com/t/using-ansbile-and-ansbile-playbook-with-just-the-password-for-the-remote-host/13664>\
**Category:** Ansible Project\
**Created:** [October 11, 2013, 2:52pm UTC](https://forum.ansible.com/t/using-ansbile-and-ansbile-playbook-with-just-the-password-for-the-remote-host/13664 "2013-10-11T14:52:17Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Soumya\_Simanta](https://avatars.discourse-cdn.com/v4/letter/s/57b2e6/32.png) [@Soumya\_Simanta](https://forum.ansible.com/u/Soumya_Simanta)\
**Post date:** [October 11, 2013, 2:52pm UTC](https://forum.ansible.com/t/using-ansbile-and-ansbile-playbook-with-just-the-password-for-the-remote-host/13664/1 "2013-10-11T14:52:17Z")

</div>

I’m new to Ansible. I know I can add the ssh keys to the remote host(s) and that works. But I was wondering if there is a way to do it without sharing keys and just putting a password every time the Ansible playbook is executed.

I tried the following and they don’t work.

$ansible myhost -m ping -i ansibile\_hosts -u myuserid --private-key=~/.ssh/mykey\_rsa --ask-pass

$ansible myhost -m ping -i ansibile\_hosts -u myuserid --ask-pass

Thanks.  
-Soumya

---

<div class="post-metadata">

**Author:** ![James\_Cammarata1](https://avatars.discourse-cdn.com/v4/letter/j/d26b3c/32.png) [@James\_Cammarata1](https://forum.ansible.com/u/James_Cammarata1)\
**Post date:** [October 11, 2013, 6:28pm UTC](https://forum.ansible.com/t/using-ansbile-and-ansbile-playbook-with-just-the-password-for-the-remote-host/13664/2 "2013-10-11T18:28:26Z")

</div>

Could you please explain how they’re not working? Using --ask-pass is the correct option to have Ansible prompt you for a password. If you’re using SSH as your connection type (or “smart”, on a system that is not RHEL/CentOS 6), you can also add -vvvv to get SSH debugging info printed out.

---

<div class="post-metadata">

**Author:** ![Soumya\_Simanta](https://avatars.discourse-cdn.com/v4/letter/s/57b2e6/32.png) [@Soumya\_Simanta](https://forum.ansible.com/u/Soumya_Simanta)\
**Post date:** [October 11, 2013, 7:08pm UTC](https://forum.ansible.com/t/using-ansbile-and-ansbile-playbook-with-just-the-password-for-the-remote-host/13664/3 "2013-10-11T19:08:55Z")

</div>

If I do a normal ssh to the machine it works.  
$ssh myhost  
user@myhost’s password:

Last login: Thu Oct 10 13:15:40 2013 from xxxxxxxx

However when I do any of the following:

$ansible myhost -m ping -i ansibile\_hosts -u myuserid --private-key=~/.ssh/mykey\_rsa --ask-pass -vvvv

$ansible myhost -m ping -i ansibile\_hosts -u myuserid --ask-pass -vvvv

this what I get, I’m using the same password as I used for my ssh login above.

SSH password:  
\<x.x.x.x\> ESTABLISH CONNECTION FOR USER: myuserid  
x.x.x.x | FAILED =\> to use the ‘ssh’ connection type with passwords, you must install the sshpass program

Do I really need sshpass for this work ? I’m on a OS-X (12.5.0 Darwin Kernel Version 12.5.0: Mon Jul 29 16:33:49 PDT 2013; root:xnu-2050.48.11~1/RELEASE\_X86\_64 x86\_64) and looks like it’s not easy to install sshpass using port or brew.

Thanks.

---

<div class="post-metadata">

**Author:** ![James\_Cammarata1](https://avatars.discourse-cdn.com/v4/letter/j/d26b3c/32.png) [@James\_Cammarata1](https://forum.ansible.com/u/James_Cammarata1)\
**Post date:** [October 11, 2013, 7:12pm UTC](https://forum.ansible.com/t/using-ansbile-and-ansbile-playbook-with-just-the-password-for-the-remote-host/13664/4 "2013-10-11T19:12:58Z")

</div>

Yes, unfortunately that is a requirement when using the --ask-pass option.

---

<div class="post-metadata">

**Author:** ![Soumya\_Simanta](https://avatars.discourse-cdn.com/v4/letter/s/57b2e6/32.png) [@Soumya\_Simanta](https://forum.ansible.com/u/Soumya_Simanta)\
**Post date:** [October 11, 2013, 7:34pm UTC](https://forum.ansible.com/t/using-ansbile-and-ansbile-playbook-with-just-the-password-for-the-remote-host/13664/5 "2013-10-11T19:34:37Z")

</div>

Thanks.

---

<div class="post-metadata">

**Author:** ![Mona\_Gopal](https://avatars.discourse-cdn.com/v4/letter/m/b4bc9f/32.png) [@Mona\_Gopal](https://forum.ansible.com/u/Mona_Gopal)\
**Post date:** [October 3, 2016, 10:28am UTC](https://forum.ansible.com/t/using-ansbile-and-ansbile-playbook-with-just-the-password-for-the-remote-host/13664/6 "2016-10-03T10:28:22Z")

</div>

Hi,

I am facing a similar issue.  
I have non-root access to a server to which i am able to connect manually.  
But ansible throws “to use the ‘ssh’ connection type with passwords, you must install the sshpass program” error when i execute the playbook.  
My hosts file contains the ip address and credentials to login to that server in the below format  
ip ansible\_ssh\_user=“non-root-user” ansible\_ssh\_pass=“password”

Is it necessary to install sshpass on the remote node as well??

I do not have root access, so how do i go about it?

Please suggest ASAP

Thanks in advance,  
Mona G

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [October 3, 2016, 10:39am UTC](https://forum.ansible.com/t/using-ansbile-and-ansbile-playbook-with-just-the-password-for-the-remote-host/13664/7 "2016-10-03T10:39:54Z")

</div>

Not on the remote node, but you need sshpass on your Ansible control machine.

---

<div class="post-metadata">

**Author:** ![Mona\_Gopal](https://avatars.discourse-cdn.com/v4/letter/m/b4bc9f/32.png) [@Mona\_Gopal](https://forum.ansible.com/u/Mona_Gopal)\
**Post date:** [October 7, 2016, 10:21am UTC](https://forum.ansible.com/t/using-ansbile-and-ansbile-playbook-with-just-the-password-for-the-remote-host/13664/8 "2016-10-07T10:21:11Z")

</div>

Hi Kai,

I have installed openssh-server and openssh-clients on the control machine and the error still persists.  
Any other way forward??

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [October 7, 2016, 12:03pm UTC](https://forum.ansible.com/t/using-ansbile-and-ansbile-playbook-with-just-the-password-for-the-remote-host/13664/9 "2016-10-07T12:03:34Z")

</div>

Did you install the package "sshpass" on the control machine? (Non-interactive ssh password authentication).  
Ansible doesn't require openssh-server on the control machine, but when you are using ssh with password the program "sshpass" is needed on the control machine since ssh doesn’t provide this functionality itself.

---

<div class="post-metadata">

**Author:** ![Mona\_Gopal](https://avatars.discourse-cdn.com/v4/letter/m/b4bc9f/32.png) [@Mona\_Gopal](https://forum.ansible.com/u/Mona_Gopal)\
**Post date:** [October 19, 2016, 11:00am UTC](https://forum.ansible.com/t/using-ansbile-and-ansbile-playbook-with-just-the-password-for-the-remote-host/13664/10 "2016-10-19T11:00:06Z")

</div>

Hi Kai,

I have installed openssh-server and openssh-clients on the control machine using yum.  
And still getting the error: | FAILED =\> to use the ‘ssh’ connection type with passwords, you must install the sshpass program

Regards,  
Mona G
