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

4,661 views
Skip to first unread message

Soumya Simanta

unread,
Oct 11, 2013, 10:52:17 AM10/11/13
to ansible...@googlegroups.com
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

James Cammarata

unread,
Oct 11, 2013, 2:28:26 PM10/11/13
to ansible...@googlegroups.com
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.


--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--

James Cammarata <jcamm...@ansibleworks.com>
Sr. Software Engineer, AnsibleWorks, Inc.
http://www.ansibleworks.com/

Soumya Simanta

unread,
Oct 11, 2013, 3:08:55 PM10/11/13
to ansible...@googlegroups.com
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. 

James Cammarata

unread,
Oct 11, 2013, 3:12:58 PM10/11/13
to ansible...@googlegroups.com
Yes, unfortunately that is a requirement when using the --ask-pass option.

Soumya Simanta

unread,
Oct 11, 2013, 3:34:37 PM10/11/13
to ansible...@googlegroups.com
Thanks. 

Mona Gopal

unread,
Oct 3, 2016, 6:28:22 AM10/3/16
to Ansible Project
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

Kai Stian Olstad

unread,
Oct 3, 2016, 6:40:07 AM10/3/16
to ansible...@googlegroups.com
On 03.10.2016 12:28, Mona Gopal wrote:
> 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?

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

--
Kai Stian Olstad

Mona Gopal

unread,
Oct 7, 2016, 6:21:12 AM10/7/16
to Ansible Project, ansible-pr...@olstad.com
Hi Kai,

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

Kai Stian Olstad

unread,
Oct 7, 2016, 8:06:45 AM10/7/16
to ansible...@googlegroups.com
On 07.10.2016 12:21, Mona Gopal wrote:
> On Monday, October 3, 2016 at 4:10:07 PM UTC+5:30, Kai Stian Olstad
> wrote:
>>
>> On 03.10.2016 12:28, Mona Gopal wrote:
>> > 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?
>>
>> Not on the remote node, but you need sshpass on your Ansible control
>> machine.
>>
>
> I have installed openssh-server and openssh-clients on the control
> machine
> and the error still persists.
> Any other way forward??

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.

--
Kai Stian Olstad

Mona Gopal

unread,
Oct 19, 2016, 7:00:06 AM10/19/16
to Ansible Project, ansible-pr...@olstad.com
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
Reply all
Reply to author
Forward
0 new messages