Last active
July 18, 2016 15:58
-
-
Save colorstain/79aa4180cebb7992ee9f445e15bc653f to your computer and use it in GitHub Desktop.
Copy SSH Keys to remote servers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- name: Copy SSH key | |
hosts: all | |
serial: "{{ serial|default(1) }}" | |
tasks: | |
- name: Get the name of the user running the script | |
local_action: command whoami | |
register: username_on_host | |
- name: Copy ssh key to server | |
authorized_key: | |
user: "{{ username_on_host.stdout }}" | |
key: "{{ lookup('file', '/Users/{{ username_on_host.stdout }}/.ssh/id_rsa.pub') }}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment