_ryxma
Last Updated: January 12, 2017
·
20.91K
· brunochauvet

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

2 Responses
Add your response

28037

Why /root/ ?

over 1 year ago ·
28491

How about using user -module and generate_ssh_key?

over 1 year ago ·
Filed Under