You can use ssh, with ssh public/private keys to do this securely with rsync.
ssh can authenticate with a password, or with a public/private keypair.
In this answer I will cover how to setup an ssh public/private key pair. Describe ssh-agent forwarding, and how to use them with rsync to sync two remote machines.
SSH public/private key
You can generate an ssh key pair by using
ssh-keygen, it will prompt you for a passphrase, you will want to enter something secure here. it will also generate two files $HOME/.ssh/id_rsa (don't share this), and $HOME/.ssh/id_rsa.pub.
The public key (id_rsa.pub) can be shared with anyone without fear of your account being compromised by them. If someone gets a hold of your private key then they can authenticate to any account/machine that is set up to accept your private key.
This is where the passphrase comes in, it makes it so if someone gets your private key they still need to know the passphrase.
During login ssh looks for a file at $HOME/.ssh/authorized_keys. This file is a list of public keys that are authorized to be used for authentication. On your remote machines you will want to append your id_rsa.pub to this file.
During ssh attempts you will now be prompted for your passphrase to your private key instead of your password.
You can avoid having to type your passphrase over and over by using
ssh-agent bash, followed by
ssh-add. This first runs bash with a "keyring" attached to it, then adds your key to the keyring. Now, while in this shell if ssh is called it will pull your private key from the keyring instead of prompting you for the passphrase.
AllowAgentForwarding yes in /etc/ssh/sshd_config on the remote hosts. This makes it so you can ssh from a machine you have sshed to, to another one that has your public key in authorized_keys and you won't be prompted for a password, or passphrase, as it will handle the communication back to the keychain at your source machine.
ssh lets you issue a command at the remote machine without giving you a shell, if you have the above setup you can do the following:
ssh user1@remote_host1 'hostname;id'
This will run the commands hostname, and id on remote_host1 and use your key without prompting you. It should return "remote_host1, user1"
You could also demonstrate the agent forwarding with
ssh user1@remote_host1 'ssh user2@remote_host2 "hostname;id"'
This will run ssh
user2@remote_host2 "hostname;id" on remote_host1 wich will then ssh to remote_host2 and run the commands their. It hand back the authentication request to your machine as agent forwarding is on and use your key without prompting you. It should return "remote_host2, user2"
You can now do the following.
ssh remote_host1_user@remote_host1 "rsync -ave ssh source_sync_dir remote_host2_user@remote_host2:target_sync_dir"
This tells remote_host1 to rsync the source on host_1 with the destination on host_2, and rsync has been told to use ssh, which will use your forwarded key.