Trying to push locally stored .pub keys to the "authorized_keys" on a remote host

72 views
Skip to first unread message

Dave Florek

unread,
Sep 21, 2017, 4:47:49 PM9/21/17
to Ansible Project
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,

Matt Martz

unread,
Sep 21, 2017, 4:53:16 PM9/21/17
to ansible...@googlegroups.com
The docs for the authorized_key module has an example that covers this exact case:


- name: Set authorized key took from file
  authorized_key:
    user: charlie
    state: present
    key: "{{ lookup('file', '/home/charlie/.ssh/id_rsa.pub') }}"

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscribe@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/9569d4f0-c58f-4986-8004-deefe671c839%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Matt Martz
@sivel
sivel.net

Kai Stian Olstad

unread,
Sep 21, 2017, 4:53:22 PM9/21/17
to ansible...@googlegroups.com
That's what the first example in the module documentation does.


--
Kai Stian Olstad

Dave Florek

unread,
Sep 21, 2017, 5:22:19 PM9/21/17
to Ansible Project
I see. I'm not thinking abstractly enough. Thanks!
Reply all
Reply to author
Forward
0 new messages