Synchronizing two computers bridging using rsync

I want to sync two computers (A and C). Unfortunately I cannot connect from computer A to computer C via ssh (nobody knows why). This is why I have to use another computer (B) that is recognized by C.

To sync A and C, I create two scripts, the first one "sync_A_2_B.sh" (located in A) and "sync_B_2_C.sh" (located in B). Each of them contains rsync instructions.

A to B:

rsync -av ~/BACK_UP/ username1@blablabla1:/home/BACK_UP/

      

B to C:

rsync -av ~/BACK_UP/ username2@blablabla2:/home/BACK_UP/

      

This works great, but it takes a little time. This leads to my question. Is it possible to do these steps in a single script located at ("" sync_A_2_C.sh) so that the program thinks B is a bridge? I linked the following, but it doesn't work:

rsync -av ~/BACK_UP/ username1@blablabla1:/home/BACK_UP/
rsync -av username1@blablabla1:/home/BACK_UP/ username2@blablabla2:/home/BACK_UP/

      

However, it does not work as the source and target cannot be on the remmote desktop at the same time. Is it possible to easily do what I want? Should I use a different tool?

+3


source to share


1 answer


You can use the ProxyCommand option for ssh to forward traffic through B. This means that the files should not live on machine B at all. For example (going from machine A to C):

rsync -av -e 'ssh -o "ProxyCommand ssh -W %h:%p username1@B"' ~/BACK_UP/ username2@C:/home/BACK_UP/

      

Or you can put the ProxyCommand in your ~ / .ssh / config file. Something like:



Host C
   Hostname C
   User username2
   ProxyCommand ssh -W %h:%p username1@B

      

With this you have to make ssh transparently from A to C

+4


source







All Articles