# How to add multiple ssh keys from Github to a single deploy-style user?

**URL:** <https://forum.ansible.com/t/how-to-add-multiple-ssh-keys-from-github-to-a-single-deploy-style-user/27295>\
**Category:** Ansible Project\
**Created:** [April 17, 2018, 1:29am UTC](https://forum.ansible.com/t/how-to-add-multiple-ssh-keys-from-github-to-a-single-deploy-style-user/27295 "2018-04-17T01:29:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ejfeldhusen](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/ejfeldhusen/32/4584_2.png) [@ejfeldhusen](https://forum.ansible.com/u/ejfeldhusen)\
**Post date:** [April 17, 2018, 1:29am UTC](https://forum.ansible.com/t/how-to-add-multiple-ssh-keys-from-github-to-a-single-deploy-style-user/27295/1 "2018-04-17T01:29:14Z")

</div>

I have a user that is a deploy-style user for a specific project, so I’m trying to figure out if it’s possible to use the authorized\_key module to do that.

I’ve tried something like this below and I get an error attempting to run it.

tasks:

- name: Set deploy-user authorized key from github url  
authorized\_key:  
user: deploy-user  
state: present  
key:
- [https://github.com/username1.keys](https://github.com/username1.keys)
- [https://github.com/username2.keys](https://github.com/username2.keys)
- [https://github.com/username3.keys](https://github.com/username3.keys)

I’ve tried a couple of other options with no luck.

Any suggestions?

Eric Feldhusen

---

<div class="post-metadata">

**Author:** ![Karl\_Auer](https://avatars.discourse-cdn.com/v4/letter/k/cc9497/32.png) [@Karl\_Auer](https://forum.ansible.com/u/Karl_Auer)\
**Post date:** [April 17, 2018, 2:57am UTC](https://forum.ansible.com/t/how-to-add-multiple-ssh-keys-from-github-to-a-single-deploy-style-user/27295/2 "2018-04-17T02:57:10Z")

</div>

Maybe loop across a list of the keys? Suggestion from deep ignorance…

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [April 17, 2018, 5:03am UTC](https://forum.ansible.com/t/how-to-add-multiple-ssh-keys-from-github-to-a-single-deploy-style-user/27295/3 "2018-04-17T05:03:46Z")

</div>

@Eric, normally you should include the error you get, from the email  
it looks like an indentation issue, also key takes a string, not a  
list.  
That string could be a set of keys in each line though.

This should work:

tasks:  
&nbsp;&nbsp;- name: Set deploy-user authorized key from github url  
&nbsp;&nbsp;&nbsp;&nbsp;authorized\_key:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;user: deploy-user  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;state: present  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;key: '{{item}}'  
&nbsp;&nbsp;&nbsp;&nbsp;loop:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- [https://github.com/username1.keys](https://github.com/username1.keys)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- [https://github.com/username2.keys](https://github.com/username2.keys)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- [https://github.com/username3.keys](https://github.com/username3.keys)

---

<div class="post-metadata">

**Author:** ![ejfeldhusen](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/ejfeldhusen/32/4584_2.png) [@ejfeldhusen](https://forum.ansible.com/u/ejfeldhusen)\
**Post date:** [April 17, 2018, 1:32pm UTC](https://forum.ansible.com/t/how-to-add-multiple-ssh-keys-from-github-to-a-single-deploy-style-user/27295/4 "2018-04-17T13:32:13Z")

</div>

My apologies, I will do that next time.

Your suggestion worked perfect, thank you, I appreciate it.

Eric Feldhusen
