Created
April 14, 2016 17:14
-
-
Save ianling/36e923097396f4708be2a39e7f962cd8 to your computer and use it in GitHub Desktop.
Creates SSH certificates for passwordless login
This file contains hidden or 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: Set up sshcerts for MYUSER | |
hosts: all | |
remote_user: MYUSER | |
tasks: | |
- name: Generate a unique key for this host | |
local_action: command /usr/bin/ssh-keygen -b 2048 -t rsa -f /home/MYUSER/sshkeys/{{ inventory_hostname }} -q -N "" | |
- name: Create /backup/.ssh recursively | |
file: path=/home/MYUSER/.ssh state=directory owner=MYUSER group=MYUSER mode=0700 recurse=yes | |
- name: Add public key to backup user | |
authorized_key: user=MYUSER | |
key="{{ lookup('file', '/home/MYUSER/sshkeys/'+inventory_hostname+'.pub') }}" | |
state=present |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment