# Using multiple SSH keys in a template

**URL:** <https://forum.ansible.com/t/using-multiple-ssh-keys-in-a-template/38227>\
**Category:** AWX Project\
**Tags:** awx, kubernetes\
**Created:** [July 14, 2023, 12:03pm UTC](https://forum.ansible.com/t/using-multiple-ssh-keys-in-a-template/38227 "2023-07-14T12:03:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Christian\_Garling](https://avatars.discourse-cdn.com/v4/letter/c/ec9cab/32.png) [@Christian\_Garling](https://forum.ansible.com/u/Christian_Garling)\
**Post date:** [July 14, 2023, 12:03pm UTC](https://forum.ansible.com/t/using-multiple-ssh-keys-in-a-template/38227/1 "2023-07-14T12:03:31Z")

</div>

Hi folks,

I need to use two different SSH keys in a template to access all hosts in my inventory.

I followed these howto:

[How to use`SSH Keys` for Multiple Credentials In Ansible Tower? - Red Hat Customer Portal](https://access.redhat.com/solutions/3938741)

And also this one:

[How to manage multiple private keys in AWX (google.com)](https://groups.google.com/g/awx-project/c/YDrWyNihx-E/m/iNarpsazCAAJ)

But nothing worked for me. Maybe all of these howto rely on an older version of AWX before it moved to Kubernetes.

Is there any way to have multiple SSH keys in a single template that works with recent AWX versions?

Kind regards, Christian

---

<div class="post-metadata">

**Author:** ![AWX\_Project](https://avatars.discourse-cdn.com/v4/letter/a/eada6e/32.png) [@AWX\_Project](https://forum.ansible.com/u/AWX_Project)\
**Post date:** [July 14, 2023, 6:15pm UTC](https://forum.ansible.com/t/using-multiple-ssh-keys-in-a-template/38227/2 "2023-07-14T18:15:30Z")

</div>

that first link guide should still be relevant for newer version of AWX running on k8s.

Can you provide the exact error message you are getting when running the jobs?

AWX Team

---

<div class="post-metadata">

**Author:** ![Christian\_Garling](https://avatars.discourse-cdn.com/v4/letter/c/ec9cab/32.png) [@Christian\_Garling](https://forum.ansible.com/u/Christian_Garling)\
**Post date:** [July 17, 2023, 9:34am UTC](https://forum.ansible.com/t/using-multiple-ssh-keys-in-a-template/38227/3 "2023-07-17T09:34:49Z")

</div>

Hi AWX Team,

I will try to explain it all in detail.

I have an inventory with 64 hosts. 61 of them work with the standard SSH key, the other 3 hosts need a second key, because they are older and do not understand the cryptographics that will be used with the other key.  
So I created a second key, that needs to be used explicitly when I connect to these 3 hosts.

My configuration is as followed (I followed the RHEL knowledge base article):

 ![awx-multi-ssh1.png](https://us1.discourse-cdn.com/ansible/original/2X/9/9872c50c665fce1fba18ec032d55879dbe388b3f.png)

 ![awx-multi-ssh2.png](https://us1.discourse-cdn.com/ansible/original/2X/1/185ebe97fbec1da3a4fe58da4484caf9fe7390a7.png)

 ![awx-multi-ssh3.png](https://us1.discourse-cdn.com/ansible/original/2X/9/9045da1fa1a59c2493e97aa52fc9bcf4036175d1.png)

 ![awx-multi-ssh4.png](https://us1.discourse-cdn.com/ansible/original/2X/f/f4ba8f48132e16270a8f6cac242a3a0f87bc7ffe.png)

Inside the template:

![awx-multi-ssh5.png](https://us1.discourse-cdn.com/ansible/original/2X/3/3d7e317cd2be02f4906f06e848581df1058b2bcc.png)

And finally in the Variables of one of the hosts:

 ![awx-multi-ssh6.png](https://us1.discourse-cdn.com/ansible/original/2X/f/f08d981bf5c5ae3799d9333b926d02d992b36654.png)

The error message I receive:

 ![awx-multi-ssh7.png](https://us1.discourse-cdn.com/ansible/original/2X/7/74d6d13eaacdcf11914dc2dcc0480c45c5c21559.png)

I also tried the SSH keys directly in the awx-ee container:

bash-5.1$ ssh -i key1.pem ansible\_deploy@nfszvweb1  
ansible\_deploy@nfszvweb1’s password:

bash-5.1$ ssh -i key2.pem ansible\_deploy@nfszvweb1  
Welcome to Ubuntu 12.10 (GNU/Linux 3.5.0-51-generic x86\_64)

Where key1.pem is the standard SSH key I enrolled on all hosts and key2.pem is the second key to workaround the 3 older hosts.

For me it looks like, that the second SSH key will not be used within the template run.

Regards, Christian

---

<div class="post-metadata">

**Author:** ![Christian\_Garling](https://avatars.discourse-cdn.com/v4/letter/c/ec9cab/32.png) [@Christian\_Garling](https://forum.ansible.com/u/Christian_Garling)\
**Post date:** [July 24, 2023, 6:25am UTC](https://forum.ansible.com/t/using-multiple-ssh-keys-in-a-template/38227/4 "2023-07-24T06:25:11Z")

</div>

Hi together,

any news here? Did I make a mistake in the configuration?

Regards, Christian
