# Rsyncing a directory from a remote host to another remote host, with each remote host requiring separate SSH key,s user and ssh\_opts

**URL:** <https://forum.ansible.com/t/rsyncing-a-directory-from-a-remote-host-to-another-remote-host-with-each-remote-host-requiring-separate-ssh-key-s-user-and-ssh-opts/27705>\
**Category:** Ansible Project\
**Created:** [June 4, 2018, 9:15pm UTC](https://forum.ansible.com/t/rsyncing-a-directory-from-a-remote-host-to-another-remote-host-with-each-remote-host-requiring-separate-ssh-key-s-user-and-ssh-opts/27705 "2018-06-04T21:15:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![DimK](https://avatars.discourse-cdn.com/v4/letter/d/eb9ed0/32.png) [@DimK](https://forum.ansible.com/u/DimK)\
**Post date:** [June 4, 2018, 9:15pm UTC](https://forum.ansible.com/t/rsyncing-a-directory-from-a-remote-host-to-another-remote-host-with-each-remote-host-requiring-separate-ssh-key-s-user-and-ssh-opts/27705/1 "2018-06-04T21:15:05Z")

</div>

My problem is pretty simple, but so hard to solve with Ansible.

I want to rsync a directory from a remote host to another remote host. The internet says I should use delegate\_to for the source machine to copy to the host/target machine.

Problem is that the two machines require different pem (SSH) keys to access them, require a different user and also require different SSH options (one of them must be connected to Proxy command).

The hard part comes from the fact that delegate\_to only allows you to put the address, port and maybe the user for the delegated\_to/source machine. I don’t know how I can define different SSH keys for the “host” and the “delegate\_to” boxes, or how to specify different SSH options for each.

I don’t usually ask such “noob” questions like this but there is no concrete information on the web and documentation on delegation is pretty light…

Please help, I am stuck on this…
