The other day I had an interesting situation to solve:
I have some data on machine B and I want it copied on machine C. However, machines B and C have no direct connection (known_hosts), but machine A can connect to B and C without password.
It is obvious that one needs to use machine A as a proxy between B and C.
[B] ---> [A] ---> [C]
After a while thinking of tunnelling and using some sort of actual network proxy, I realised that I/O would also do the trick: We can have a command runing on B to output data to
stdout and another command running on C reading from
stdin. The end command would look something like:
user2are the users under which machine A has password-less access to B and C respectively
src_diris the location where data is
dest_diris the location where data needs to be copied to
- We change to
src_dirfirst in order to have the archive with a relative path to the actual data that needs to be copied. Otherwise, the path in
dest_dirwill also contain
-zis used to compress/decompress data via
gzip. One can use
bz2too if available on the source/dest machines.
- While using
-zresults in less data transferred between machines, the CPU impact of the compression may result in longer copy times. My particular case worked best without the
- Depending on the number of files to be copied, you might want to also drop the verbosity flag at destination (
Taking into account the above, my fastest variant of the commant is: