# Configuring ssh passwordless access for a user

**URL:** <https://forum.ansible.com/t/configuring-ssh-passwordless-access-for-a-user/14855>\
**Category:** Ansible Project\
**Tags:** rhel\
**Created:** [March 25, 2014, 3:05pm UTC](https://forum.ansible.com/t/configuring-ssh-passwordless-access-for-a-user/14855 "2014-03-25T15:05:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tim.j.culhane](https://avatars.discourse-cdn.com/v4/letter/t/90ced4/32.png) [@tim.j.culhane](https://forum.ansible.com/u/tim.j.culhane)\
**Post date:** [March 25, 2014, 3:05pm UTC](https://forum.ansible.com/t/configuring-ssh-passwordless-access-for-a-user/14855/1 "2014-03-25T15:05:23Z")

</div>

Hi There,

I’m attempting to configure ssh access to a user via ansible, as described in the blog entry at:  
[http://www.hashbangcode.com/blog/ansible-ssh-setup-playbook](http://www.hashbangcode.com/blog/ansible-ssh-setup-playbook)

I’m running this playbook using ansible version 1.4.5 on rhel 6.3.

My inventory hosts file looks like:

[hosts]  
172.20.0.36 ansible\_connection=ssh ansible\_ssh\_user=deployment ansible\_ssh\_pass=password

I have sshpass installed:

[ansible@rwc-host1 inventory]$ sudo yum list | grep sshpass  
sshpass.x86\_64 1.05-1.el6 @epel

My ansible.cfg file looks like this:

[ansible@rwc-host1 inventory]$ cat ansible.cfg  
[defaults]  
host\_key\_checking=False  
[ansible@rwc-host1 inventory]$

I already have the user created on the remote server with sudo access, so all the playbook really needs to do is take the contents of id\_rsa.pub and add it to the authorized\_keys file for the remote user.

The user I’m connecting as is the same as the user who’s authorized\_keys file I want to create.

However, the user I’m running the playbook as on the ansible control machine is different.  
For example, the control user is named ‘ansible’ and the remote user is named ‘deployment’

The playbook file is:

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [March 25, 2014, 7:25pm UTC](https://forum.ansible.com/t/configuring-ssh-passwordless-access-for-a-user/14855/2 "2014-03-25T19:25:03Z")

</div>

Ansible does read ansible.cfg.

The error about not matching hosts is probably a thing about what groups and hosts you have defined vs your playbooks.

---

<div class="post-metadata">

**Author:** ![tim.j.culhane](https://avatars.discourse-cdn.com/v4/letter/t/90ced4/32.png) [@tim.j.culhane](https://forum.ansible.com/u/tim.j.culhane)\
**Post date:** [March 27, 2014, 10:25am UTC](https://forum.ansible.com/t/configuring-ssh-passwordless-access-for-a-user/14855/3 "2014-03-27T10:25:06Z")

</div>

Hi Michael,

My hosts file is simply:

[hosts]

172.20.0.36 ansible\_connection=ssh ansible\_ssh\_user=deployment ansible\_ssh\_pass=password

and in the playbook I use:

- name: configure authorized\_keys

hosts: hosts

user: deployment

sudo: yes

So not sure why there should be a problem in that instance?

However, my main issue is getting ssh working?

Thanks,

Tim

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [March 27, 2014, 6:04pm UTC](https://forum.ansible.com/t/configuring-ssh-passwordless-access-for-a-user/14855/4 "2014-03-27T18:04:14Z")

</div>

Your host file might need to be pathed with -i if it’s in an unexpected location.
