# Using ansible\_ssh\_private\_key\_file variable vs --private-key

**URL:** <https://forum.ansible.com/t/using-ansible-ssh-private-key-file-variable-vs-private-key/15178>\
**Category:** Ansible Project\
**Tags:** ubuntu\
**Created:** [May 7, 2014, 1:22am UTC](https://forum.ansible.com/t/using-ansible-ssh-private-key-file-variable-vs-private-key/15178 "2014-05-07T01:22:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stuart\_Reynolds](https://avatars.discourse-cdn.com/v4/letter/s/90ced4/32.png) [@Stuart\_Reynolds](https://forum.ansible.com/u/Stuart_Reynolds)\
**Post date:** [May 7, 2014, 1:22am UTC](https://forum.ansible.com/t/using-ansible-ssh-private-key-file-variable-vs-private-key/15178/1 "2014-05-07T01:22:13Z")

</div>

I can call:

`ansible all -m ping -i DevHosts --user=ubuntu --private-key=../DevMongo.pem`

with DevHosts:

`[mongo] 1.2.3.4`

and ansible will correctly connect to the host. But if I try and store these parameters in an inventory: (as suggested [here](http://docs.ansible.com/intro_inventory.html) )

`  
[mongo]  
1.2.3.4 ansible\_ssh\_user=ubuntu ansible\_ssh\_private\_key\_file=…/DevMongo.pem

`

`ansible all -m ping -i DevHosts`

… gives me: 1.2.3.4 | FAILED =\> FAILED: No authentication methods available.

Are --private-key and ansible\_ssh\_private\_key\_file related? What am I missing here?

Cheers

- Stuart

---

<div class="post-metadata">

**Author:** ![Stuart\_Reynolds](https://avatars.discourse-cdn.com/v4/letter/s/90ced4/32.png) [@Stuart\_Reynolds](https://forum.ansible.com/u/Stuart_Reynolds)\
**Post date:** [June 25, 2014, 6:21pm UTC](https://forum.ansible.com/t/using-ansible-ssh-private-key-file-variable-vs-private-key/15178/2 "2014-06-25T18:21:24Z")

</div>

Seems like feature was fixed/added between v0.9 and 1.7. (0.9 is what apt-get still provides for Ubunutu 12.04 LTS). Switching to the git version solved this.

- Stuart
