when creating user(s) with SSH PasswordAuthenication, there doesn't appear to be an issue. However, creating users(s) with SSH Key Authentication, I'm not sure I understand the workflow.

I want to create a user account with SSH Key Authentication, across other linux servers. On my admin box, I can provision these users with ansible, across many other linux servers with Password Authentication,

I want SSH Key Authentication.

How can you provision a new account across many servers it's own user SSH Key?

I seems, you have the following workflow with ansible;

  • enable PasswordAuthenication in sshd_config, among all servers (including the admin system).
  • create the account(s)
  • have the new user login (admin box), and create there own SSH Key.
  • The new user submits the public key to the provisioning admin.
  • The provisioning admin copies the key to all servers,
  • then disable PasswordAuthenicaiton in sshd_config

Does that sound right, or is there a better way ?

thank you for your help.


You will need to use the authorized_key_module as well. The flow to add a user to a server with a specific ssh key should be:


- name: Ensure user is present.
    name: user
    state: present

- name: Set authorized key took from file
    user: user
    state: present
    key: id_rsa.pub

Disabling password authentication should be part of the in initial Ansible setup.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.