# How to use custom private key with ansible?

**URL:** <https://forum.ansible.com/t/how-to-use-custom-private-key-with-ansible/15572>\
**Category:** Ansible Project\
**Tags:** ubuntu\
**Created:** [June 28, 2014, 8:51pm UTC](https://forum.ansible.com/t/how-to-use-custom-private-key-with-ansible/15572 "2014-06-28T20:51:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andrei\_Pashkin](https://avatars.discourse-cdn.com/v4/letter/a/a87d85/32.png) [@Andrei\_Pashkin](https://forum.ansible.com/u/Andrei_Pashkin)\
**Post date:** [June 28, 2014, 8:51pm UTC](https://forum.ansible.com/t/how-to-use-custom-private-key-with-ansible/15572/1 "2014-06-28T20:51:16Z")

</div>

What is the analog for `:`

> `ssh -i my_key.pem [ubuntu@123.123.123.123](mailto:ubuntu@123.123.123.123)`

in Ansible?

---

<div class="post-metadata">

**Author:** ![Jim\_Richardson](https://avatars.discourse-cdn.com/v4/letter/j/d07c76/32.png) [@Jim\_Richardson](https://forum.ansible.com/u/Jim_Richardson)\
**Post date:** [June 28, 2014, 8:53pm UTC](https://forum.ansible.com/t/how-to-use-custom-private-key-with-ansible/15572/2 "2014-06-28T20:53:51Z")

</div>

--private-key=PRIVATE\_KEY\_FILE

---

<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:** [June 29, 2014, 12:48am UTC](https://forum.ansible.com/t/how-to-use-custom-private-key-with-ansible/15572/3 "2014-06-29T00:48:10Z")

</div>

This also can be set on a per host or group basis with ansible\_ssh\_private\_key\_file, which can be useful if different pems are needed for different sets of machines.

[http://docs.ansible.com/intro\_inventory.html#id10](http://docs.ansible.com/intro_inventory.html#id10)

---

<div class="post-metadata">

**Author:** ![Andrei\_Pashkin](https://avatars.discourse-cdn.com/v4/letter/a/a87d85/32.png) [@Andrei\_Pashkin](https://forum.ansible.com/u/Andrei_Pashkin)\
**Post date:** [July 2, 2014, 6:18am UTC](https://forum.ansible.com/t/how-to-use-custom-private-key-with-ansible/15572/4 "2014-07-02T06:18:56Z")

</div>

Thanks!
