# Bootstrapping host using ansible ?

**URL:** <https://forum.ansible.com/t/bootstrapping-host-using-ansible/20214>\
**Category:** Ansible Project\
**Created:** [January 14, 2016, 3:55pm UTC](https://forum.ansible.com/t/bootstrapping-host-using-ansible/20214 "2016-01-14T15:55:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Christophe\_Meessen](https://avatars.discourse-cdn.com/v4/letter/c/b2d939/32.png) [@Christophe\_Meessen](https://forum.ansible.com/u/Christophe_Meessen)\
**Post date:** [January 14, 2016, 3:55pm UTC](https://forum.ansible.com/t/bootstrapping-host-using-ansible/20214/1 "2016-01-14T15:55:44Z")

</div>

Forgive me this possibly naive question, I’m new to ansible.

I would like to upload the public key used for ssh authentication with ansible.  
There is an ansible module ([http://docs.ansible.com/ansible/authorized\_key\_module.html](http://docs.ansible.com/ansible/authorized_key_module.html)) to do that.

But I can’t find an example how to call it directly (not from a playbook).

The problem is the key argument for which I have a file. From the documentation I need to pass the argument value

```auto
key="{{ lookup('file', 'id_rsa_ansible.pub') }}"

How do I do that on the command line ?

I expect something like this

$ ansible all -m authorized_key -a "user=root key=xxx" --ask-pass 

```

What should I put at the ‘xxx’ ?

---

<div class="post-metadata">

**Author:** ![David\_Karban](https://avatars.discourse-cdn.com/v4/letter/d/90db22/32.png) [@David\_Karban](https://forum.ansible.com/u/David_Karban)\
**Post date:** [January 14, 2016, 4:24pm UTC](https://forum.ansible.com/t/bootstrapping-host-using-ansible/20214/2 "2016-01-14T16:24:36Z")

</div>

Hi, in this invocation you need to supply key itself to ‘key’ parameter.

David

Dne 14. 1. 2016 17:01 napsal uživatel “Christophe Meessen” \<[christophe.meessen@gmail.com](mailto:christophe.meessen@gmail.com)\>:

---

<div class="post-metadata">

**Author:** ![Larry\_Smith1](https://avatars.discourse-cdn.com/v4/letter/l/d26b3c/32.png) [@Larry\_Smith1](https://forum.ansible.com/u/Larry_Smith1)\
**Post date:** [January 15, 2016, 6:06am UTC](https://forum.ansible.com/t/bootstrapping-host-using-ansible/20214/3 "2016-01-15T06:06:58Z")

</div>

@Christophe - I bootstrap my hosts with a few roles in which one of those is to upload ssh keys and another one to manager users which I run prior to the SSH key role.

[https://github.com/mrlesmithjr/ansible-manage-ssh-keys](https://github.com/mrlesmithjr/ansible-manage-ssh-keys)  
[https://github.com/mrlesmithjr/ansible-users](https://github.com/mrlesmithjr/ansible-users)
