Skip to content

Instantly share code, notes, and snippets.

@mgedmin
Created September 10, 2015 13:19
Show Gist options
  • Save mgedmin/86595f4a80cc2f087488 to your computer and use it in GitHub Desktop.
Save mgedmin/86595f4a80cc2f087488 to your computer and use it in GitHub Desktop.
Creating and distributing SSH keys
- name: ssh private key for pushing backups
command: ssh-keygen -q -t rsa -N '' -f {{ backup_pusher_key }} -C backup-script@{{ ansible_fqdn }}
args:
creates: "{{ backup_pusher_key }}"
tags: [ backups, ssh ]
- name: get the ssh public key
command: cat "{{ backup_pusher_key }}.pub"
register: pubkey_result
changed_when: false
always_run: yes
tags: [ backups, ssh ]
- name: install ssh public key on the backup buddy
authorized_key: key="{{ pubkey_result.stdout }}" user=uploader state=present
delegate_to: "{{ backup_buddy }}"
tags: [ backups, ssh ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment