# Trying to push locally stored .pub keys to the "authorized\_keys" on a remote host

**URL:** <https://forum.ansible.com/t/trying-to-push-locally-stored-pub-keys-to-the-authorized-keys-on-a-remote-host/25569>\
**Category:** Ansible Project\
**Created:** [September 21, 2017, 8:47pm UTC](https://forum.ansible.com/t/trying-to-push-locally-stored-pub-keys-to-the-authorized-keys-on-a-remote-host/25569 "2017-09-21T20:47:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dave](https://avatars.discourse-cdn.com/v4/letter/d/ee7513/32.png) [@Dave](https://forum.ansible.com/u/Dave)\
**Post date:** [September 21, 2017, 8:47pm UTC](https://forum.ansible.com/t/trying-to-push-locally-stored-pub-keys-to-the-authorized-keys-on-a-remote-host/25569/1 "2017-09-21T20:47:48Z")

</div>

Hi,

I’m looking at the Ansible ‘authorized\_key’ module and I’m unable to figure out whether it’s possible to push locally stored .pub keys to the authorized\_keys file on a remote host. I don’t want to go the route of uploading .pub keys to a webserver and use URL links to transfer the keys to the target machine’s ‘authorized\_key’ file. Is there another way to achieve this via Ansible? Please let me know if I’m not making much sense.

thanks,

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [September 21, 2017, 8:52pm UTC](https://forum.ansible.com/t/trying-to-push-locally-stored-pub-keys-to-the-authorized-keys-on-a-remote-host/25569/2 "2017-09-21T20:52:24Z")

</div>

The docs for the authorized\_key module has an example that covers this exact case:

[http://docs.ansible.com/ansible/latest/authorized\_key\_module.html](http://docs.ansible.com/ansible/latest/authorized_key_module.html)

- name: Set authorized key took from file  
authorized\_key:  
user: charlie  
state: present  
key: “{{ lookup(‘file’, ‘/home/charlie/.ssh/id\_rsa.pub’) }}”

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [September 21, 2017, 8:52pm UTC](https://forum.ansible.com/t/trying-to-push-locally-stored-pub-keys-to-the-authorized-keys-on-a-remote-host/25569/3 "2017-09-21T20:52:58Z")

</div>

That's what the first example in the module documentation does.

---

<div class="post-metadata">

**Author:** ![Dave](https://avatars.discourse-cdn.com/v4/letter/d/ee7513/32.png) [@Dave](https://forum.ansible.com/u/Dave)\
**Post date:** [September 21, 2017, 9:22pm UTC](https://forum.ansible.com/t/trying-to-push-locally-stored-pub-keys-to-the-authorized-keys-on-a-remote-host/25569/4 "2017-09-21T21:22:18Z")

</div>

I see. I’m not thinking abstractly enough. Thanks!
