# ssh-copy on new multiple hosts

**URL:** <https://forum.ansible.com/t/ssh-copy-on-new-multiple-hosts/25369>\
**Category:** Ansible Project\
**Created:** [August 30, 2017, 4:40pm UTC](https://forum.ansible.com/t/ssh-copy-on-new-multiple-hosts/25369 "2017-08-30T16:40:02Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mark\_funcion](https://avatars.discourse-cdn.com/v4/letter/m/3d9bf3/32.png) [@mark\_funcion](https://forum.ansible.com/u/mark_funcion)\
**Post date:** [August 30, 2017, 4:40pm UTC](https://forum.ansible.com/t/ssh-copy-on-new-multiple-hosts/25369/1 "2017-08-30T16:40:02Z")

</div>

Hi guys/gals,

Any way I can do ssh-copy on multiple hosts via Ansible ad-hoc? I have already added around 50 new hosts in the ansible\_hosts inventory file but hit a wall in copying ssh to those new hosts.

---

<div class="post-metadata">

**Author:** ![pixel\_fairy](https://avatars.discourse-cdn.com/v4/letter/p/6f9a4e/32.png) [@pixel\_fairy](https://forum.ansible.com/u/pixel_fairy)\
**Post date:** [August 31, 2017, 4:52am UTC](https://forum.ansible.com/t/ssh-copy-on-new-multiple-hosts/25369/2 "2017-08-31T04:52:36Z")

</div>

do you mean your ssh key?

[http://docs.ansible.com/ansible/latest/authorized\_key\_module.html](http://docs.ansible.com/ansible/latest/authorized_key_module.html)

you could do something like

ansible all -m authorizied\_key -a “user=mark key=`cat ~/.ssh/id_xor.pub`”

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [September 1, 2017, 9:22pm UTC](https://forum.ansible.com/t/ssh-copy-on-new-multiple-hosts/25369/3 "2017-09-01T21:22:49Z")

</div>

I suppose you mean "ssh-copy-id" to put your pubkey on the ~50 new  
hosts that don't have it yet.  
What do you mean by "hitting a wall"?  
Is it host keys that aren't known yet? Then disable that:  
[http://docs.ansible.com/ansible/latest/intro\_configuration.html#host-key-checking](http://docs.ansible.com/ansible/latest/intro_configuration.html#host-key-checking)

Or is it something else?

Dick

---

<div class="post-metadata">

**Author:** ![mark\_funcion](https://avatars.discourse-cdn.com/v4/letter/m/3d9bf3/32.png) [@mark\_funcion](https://forum.ansible.com/u/mark_funcion)\
**Post date:** [September 2, 2017, 6:51am UTC](https://forum.ansible.com/t/ssh-copy-on-new-multiple-hosts/25369/4 "2017-09-02T06:51:35Z")

</div>

Sorry for the confusion. Yes, i mean "ssh-copy-id" and hoping to send my pubkey on the new 50 hosts via ad-hoc ansible.

I already tried disabling host\_key\_checking in the config file but no luck. I guess our machines would require ssh keys and the only option for me is to send it to thise machines

Any other ways you can suggest sending those pubkeys in a single go?

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [September 2, 2017, 9:06am UTC](https://forum.ansible.com/t/ssh-copy-on-new-multiple-hosts/25369/5 "2017-09-02T09:06:37Z")

</div>

Well if the machines require pubkey authentication (i.e. password authentication not allowed), then you’re stuck as there would be no way to authenticate at all.  
Is that the case?  
If so you have a bootstrap issue aka chicken and egg problem, and need to provision the keys through other means (as ansible requires SSH).

Dick
