# How to manage multiple private keys in AWX

**URL:** <https://forum.ansible.com/t/how-to-manage-multiple-private-keys-in-awx/34808>\
**Category:** AWX Project\
**Tags:** awx\
**Created:** [March 19, 2021, 10:03am UTC](https://forum.ansible.com/t/how-to-manage-multiple-private-keys-in-awx/34808 "2021-03-19T10:03:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fraz\_Mahmud](https://avatars.discourse-cdn.com/v4/letter/f/c0e974/32.png) [@Fraz\_Mahmud](https://forum.ansible.com/u/Fraz_Mahmud)\
**Post date:** [March 19, 2021, 10:03am UTC](https://forum.ansible.com/t/how-to-manage-multiple-private-keys-in-awx/34808/1 "2021-03-19T10:03:29Z")

</div>

Hi Folks,

I have just imported 150+ hosts from Amazon Web Services into AWX. We have multiple private keys (PEM) for servers e.g. db servers, web servers, file servers all have their own private keys.

However, when creating TEMPLATES to deploy updates or install an application, I can only includes one credential (in this a case a private key). But because i wany to deploy to all hosts this means i need to associate multiple credentials to the same template.

How can i do this? Is this possible? Does this require a script or external managemet tools?

Any help would be greatly appreciated.

Thanks.

---

<div class="post-metadata">

**Author:** ![sdmorel](https://avatars.discourse-cdn.com/v4/letter/s/c2a13f/32.png) [@sdmorel](https://forum.ansible.com/u/sdmorel)\
**Post date:** [March 23, 2021, 8:47am UTC](https://forum.ansible.com/t/how-to-manage-multiple-private-keys-in-awx/34808/2 "2021-03-23T08:47:01Z")

</div>

Hello,

You can create custom credential types, that way you could have a credential for DB servers, another for web servers, and so on.  
The catch is, you can only associate one credential type for each job template.  
Another approach is to have one job template for each type of server and conditionally run them using a workflow template.

Good luck!

---

<div class="post-metadata">

**Author:** ![Fraz\_Mahmud](https://avatars.discourse-cdn.com/v4/letter/f/c0e974/32.png) [@Fraz\_Mahmud](https://forum.ansible.com/u/Fraz_Mahmud)\
**Post date:** [March 23, 2021, 4:31pm UTC](https://forum.ansible.com/t/how-to-manage-multiple-private-keys-in-awx/34808/3 "2021-03-23T16:31:43Z")

</div>

Hey Sergio,

Thanks for the reply. I have managed to get this to work. For the record, we have approx 100 AWS PEM/SSHkeys so we would have to create 100 custom credentials through the “credential type” menu and then insert some custom variables into the injector configuration and add some fields. See below for an example of how we set up our first credential:

**Input configuration**

fields:

- id: username  
type: string  
label: Username
- id: dev\_key  
type: string  
label: SSH Key  
secret: true  
multiline: true

Injector configuration

file:  
template.dev\_key: ‘{{ dev\_key }}’  
extra\_vars:  
dev\_ssh\_key: ‘{{ tower.filename.dev\_key }}’  
ansible\_ssh\_user: ‘{{ username }}’

I have added some screenshots for reference. This allows to us now run a single job template against multiple hosts which use multiple PEM/SSH Keys.

I have attached some screenshots for the benefit of others.

 ![AWX_1.PNG](https://us1.discourse-cdn.com/ansible/original/2X/1/1152ca77275953fbacadf4a430143be445fcd0bc.png) ![AWX_2.PNG](https://us1.discourse-cdn.com/ansible/original/2X/a/aa9b13b46c03fbabd1dcb76932c15eb5a12bf071.png) ![AWX_3.PNG](https://us1.discourse-cdn.com/ansible/original/2X/4/43b178f2989c7223c9491889c69dd60c9933b1c3.png) ![AWX_4.PNG](https://us1.discourse-cdn.com/ansible/original/2X/b/bce66c8b17823c9006010712a3c5ebf09c836178.png)

---

<div class="post-metadata">

**Author:** ![Fraz\_Mahmud](https://avatars.discourse-cdn.com/v4/letter/f/c0e974/32.png) [@Fraz\_Mahmud](https://forum.ansible.com/u/Fraz_Mahmud)\
**Post date:** [March 23, 2021, 4:33pm UTC](https://forum.ansible.com/t/how-to-manage-multiple-private-keys-in-awx/34808/4 "2021-03-23T16:33:24Z")

</div>

Forgot to mention, we also needed to pass some variable to the group/tag associated with hosts that share the same PEM/SSH keys. You can see this in the screenshots.
