I have 3 computers/servers, let's call them as computer A, computer B and computer C.
- Computer A has access via
ssh
to computer B. - Only computer B has access via
ssh
to computer C. - Computer A doesn't have access to computer C directly.
So, I want to rsync
directories from computer A to computer C, using computer B(since only computer B has access via ssh
to computer C). I want to use rsync
in a simple way, like this:
rsync -options /path_to_local IpComputerC:/path_to_remote
I'm thinking on a ssh
tunnel, but I don't know if I have to make a local port forwarding or a remote port forwarding, or if I have to make two tunnels: one from A to B and other from B to C?
Any suggestions?? I'd be really grateful.
**UPDATE: I dit it!! I created an ssh tunnel with local port forwarding, which means that I used a local port from the machine A to connect with a remote port on the machine C through the machine B. The syntax for the command is:
ssh -f -N -L local_port_machineA:ip_machineC:remoteport_machineC user_machineB@ip_machineB
In my case, remoteport_machineC shoul be port 22, because I want to rsync directories through ssh.
After that, we can execute the rsync command from the machine A, in this way:
rsync -avz -e "ssh -p local_port" /source_directory username_machineC@localhost:/target_directory
That's all. Additionally, you can add more options in the part inside the quotes, such as keys or files, etc.**