_ryxma
Last Updated: January 12, 2017
·
11.51K
· brunochauvet
Bruno chauvet author 64x64

Generate SSH keys with Ansible

If you need to generate SSH keys for your root user (or any other user) with Ansible, the following does the trick:

- name: Generate SSH keys
  shell: ssh-keygen -b 2048 -t rsa -f /root/.ssh/id_rsa -q -N ""
  args:
    creates: /root/.ssh/id_rsa
Say Thanks
Respond

2 Responses
Add your response

28037

Why /root/ ?

over 1 year ago ·
28491

How about using user -module and generate_ssh_key?

10 months ago ·
Filed Under