# Multiple ansible-vault encrypted ssh private keys

**URL:** <https://forum.ansible.com/t/multiple-ansible-vault-encrypted-ssh-private-keys/33718>\
**Category:** Ansible Project\
**Created:** [September 1, 2020, 9:15pm UTC](https://forum.ansible.com/t/multiple-ansible-vault-encrypted-ssh-private-keys/33718 "2020-09-01T21:15:55Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![william.dossett](https://avatars.discourse-cdn.com/v4/letter/w/b782af/32.png) [@william.dossett](https://forum.ansible.com/u/william.dossett)\
**Post date:** [September 1, 2020, 9:15pm UTC](https://forum.ansible.com/t/multiple-ansible-vault-encrypted-ssh-private-keys/33718/1 "2020-09-01T21:15:55Z")

</div>

Hi,

I’ve been wrangling around this all afternoon.

First of all, is it ok to have two ansible-vault encrypted files (containing ssh private keys) with the same password and use them in one playbook?

I ask because when I try to use a second one, the first one seems to stop working.

My first playbook used passwords to connect to nodes and then I used an ansible-vault encrypted private key file to scp files to another remote host. This worked fine. But I need to use ssh key to connect to the nodes… when I added

vars:

ansible\_ssh\_private\_key\_file: /vars/current\_id\_rsa

and current\_id\_rsa is ansible-vault encrypted with the same password as the first file, my scp command no longer works with the key it was using and hangs asking for password now – it seems like it is using the wrong private key from the debugging I have done…. But as I am just using the

command: scp -i vars/id\_rsa -o StrictHostKeyChecking=no /tmp/id\_rsa [user@users.workstation/Users/user/.ssh/instances\_id\_rsa](mailto:user@users.workstation/Users/user/.ssh/instances_id_rsa)

for my command and vars/id\_rsa is vault encrypted, I don’t see how that would get interfered with by setting the ansible\_ssh\_private\_key\_file.

I changed back to using password to connect to nodes and then the scp command works again…

So if that isn’t going to work, can I store my ssh private keys as a vars in a vars file, so I just have one encrypted vars file? I can’t seem to find any examples of doing this with mr google.

Thanks

Bill
