Last Updated: January 12, 2017
·
28.46K
· 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

Why /root/ ?

over 1 year ago ·

How about using user -module and generate_ssh_key?

over 1 year ago ·