# Newbie - how to associate a credential with a inventory host?

**URL:** <https://forum.ansible.com/t/newbie-how-to-associate-a-credential-with-a-inventory-host/29253>\
**Category:** AWX Project\
**Tags:** awx\
**Created:** [December 13, 2018, 4:06am UTC](https://forum.ansible.com/t/newbie-how-to-associate-a-credential-with-a-inventory-host/29253 "2018-12-13T04:06:31Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![kurrent93](https://avatars.discourse-cdn.com/v4/letter/k/a4c791/32.png) [@kurrent93](https://forum.ansible.com/u/kurrent93)\
**Post date:** [December 13, 2018, 4:06am UTC](https://forum.ansible.com/t/newbie-how-to-associate-a-credential-with-a-inventory-host/29253/1 "2018-12-13T04:06:31Z")

</div>

Hello

I’m new to Awx, so please excuse my lack of knowledge.

I have an **inventory** , which has one remote host.  
To access this remote host I use a ssh username and password. I have this added to **credentials**.

My question is, how can I associate the credentials entry with the inventory host?

Thanks

---

<div class="post-metadata">

**Author:** ![kurrent93](https://avatars.discourse-cdn.com/v4/letter/k/a4c791/32.png) [@kurrent93](https://forum.ansible.com/u/kurrent93)\
**Post date:** [December 13, 2018, 7:55pm UTC](https://forum.ansible.com/t/newbie-how-to-associate-a-credential-with-a-inventory-host/29253/2 "2018-12-13T19:55:21Z")

</div>

Hi

I got the following reply directly:

> You attach that through with job template
> 
> You create a job template and associate the credential from there

However, the problem with this is, an Inventory can have one or more hosts. Each host can have a unique credentials (not the same credentials for every host).

While a job can have more than one credentials, there doesnt seem to be any awx mechanism to associate credentials with a host.

---

<div class="post-metadata">

**Author:** ![matburt](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/matburt/32/3612_2.png) [@matburt](https://forum.ansible.com/u/matburt)\
**Post date:** [December 17, 2018, 3:26pm UTC](https://forum.ansible.com/t/newbie-how-to-associate-a-credential-with-a-inventory-host/29253/3 "2018-12-17T15:26:16Z")

</div>

That’s correct. This is a very difficult problem to solve… it’s somewhat fine if they have different ssh keys but if each host has a different password (for example) then we have no way to respond to the prompts. We’re looking to solve this in different ways down the road a little bit but in the meantime you’ll have to deal with a single credential for a run.

---

<div class="post-metadata">

**Author:** ![kurrent93](https://avatars.discourse-cdn.com/v4/letter/k/a4c791/32.png) [@kurrent93](https://forum.ansible.com/u/kurrent93)\
**Post date:** [December 17, 2018, 8:20pm UTC](https://forum.ansible.com/t/newbie-how-to-associate-a-credential-with-a-inventory-host/29253/4 "2018-12-17T20:20:27Z")

</div>

Hi Mathew

Thanks for the reply.

Perhaps, as a temporary step forward, do not support prompts in this case?

---

<div class="post-metadata">

**Author:** ![matburt](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/matburt/32/3612_2.png) [@matburt](https://forum.ansible.com/u/matburt)\
**Post date:** [December 17, 2018, 8:27pm UTC](https://forum.ansible.com/t/newbie-how-to-associate-a-credential-with-a-inventory-host/29253/5 "2018-12-17T20:27:32Z")

</div>

Possibly, but we probably aren’t going to attempt to address this in any way in the short term.

---

<div class="post-metadata">

**Author:** ![Anton\_Hughes](https://avatars.discourse-cdn.com/v4/letter/a/b5ac83/32.png) [@Anton\_Hughes](https://forum.ansible.com/u/Anton_Hughes)\
**Post date:** [December 17, 2018, 8:44pm UTC](https://forum.ansible.com/t/newbie-how-to-associate-a-credential-with-a-inventory-host/29253/6 "2018-12-17T20:44:11Z")

</div>

Understood.

Is there any recommended solution/workaround for users who have an inventory with multiple hosts (each with a unique username/password)?

---

<div class="post-metadata">

**Author:** ![matburt](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/matburt/32/3612_2.png) [@matburt](https://forum.ansible.com/u/matburt)\
**Post date:** [December 17, 2018, 8:58pm UTC](https://forum.ansible.com/t/newbie-how-to-associate-a-credential-with-a-inventory-host/29253/7 "2018-12-17T20:58:45Z")

</div>

Put ansible\_ssh\_username and ansible\_ssh\_password into the extra vars for each host (or group or whatever).

---

<div class="post-metadata">

**Author:** ![Paul\_Offord](https://avatars.discourse-cdn.com/v4/letter/p/76d3ee/32.png) [@Paul\_Offord](https://forum.ansible.com/u/Paul_Offord)\
**Post date:** [January 4, 2019, 10:32am UTC](https://forum.ansible.com/t/newbie-how-to-associate-a-credential-with-a-inventory-host/29253/8 "2019-01-04T10:32:34Z")

</div>

Hi Matthew,

I face the same issue as Anton.

I noticed you said in your post " … it’s somewhat fine if they have different ssh keys …". Can I specify a variable at the Host definition level to select a pre-defined Machine \> SSH Credential? I have common user names but differing SSH keys.

Thanks and regards…Paul

---

<div class="post-metadata">

**Author:** ![matburt](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/matburt/32/3612_2.png) [@matburt](https://forum.ansible.com/u/matburt)\
**Post date:** [January 7, 2019, 2:29pm UTC](https://forum.ansible.com/t/newbie-how-to-associate-a-credential-with-a-inventory-host/29253/9 "2019-01-07T14:29:23Z")

</div>

Unfortunately no, my statement of “it’s somewhat fine” means we could probably design a solution around that but we haven’t yet.

---

<div class="post-metadata">

**Author:** ![kurrent93](https://avatars.discourse-cdn.com/v4/letter/k/a4c791/32.png) [@kurrent93](https://forum.ansible.com/u/kurrent93)\
**Post date:** [January 7, 2019, 8:01pm UTC](https://forum.ansible.com/t/newbie-how-to-associate-a-credential-with-a-inventory-host/29253/10 "2019-01-07T20:01:28Z")

</div>

Hi Mathew

Is there any documentation for a workaround? I didnt understand what you meant by:
