OK - so the first thing that I'm going to be criticized for is using the term 'proxy'. Yes, technically what I'm about to describe does not involve a true 'proxy' in normal terms, but this was the best title I could come up with.
About 2 months ago I ran into a situation where I had to set up a mirror between 2 machines that, as luck would have it, couldn't directly talk to each other. The problem was that the data I was trying to mirror was on a box at a site that did not allow direct outside access; everything was funneled through a squid proxy.
I spent about 2 weeks trying to find a solution, which mainly involved goog'ling until my eyes bled, but I ended up with the following as a workable solution, and thought it might help someone else in the same place, so here it is:
OK, for some explanation:Code:rsync -vcrtI file -e "ssh -l user_on_proxy -i /proxy_private_key proxy_ip_address ssh -i /destination_key" destination_user@destination_IP_address:/path/to/mirror/dir/
We need to establish a connection between 2 machines over ssh using a third machine as a 'go between'. In my case machine 3 was the aforementioned squid proxy box. ssh allows you to send a command automatically following your login, so
would log you in as user to machine and run the command pwd. What I did was to pass to my first ssh command a second ssh command. In essence I did 2 ssh logins, the first to the proxy box, and the second to my destination. rsync was more than happy to establish and use this connection, and I've been getting my mirror ever since.Code:ssh user@machine pwd
Please note the double-quotes, as placement of these is critical so that flags are passed properly between commands.
The command above assumes that you are using automatic log-in through the use of priv/pub keys. There are other HowTos describing how to set those up, and for brevity's sake I won't repeat them. Needless to say you need 2 sets of keys for this method to work. The source machine will have a private key, with a matching public on the proxy. The proxy will have a private key as well, with its matching public on the destination machine. Thus both connections happen automatically and the rsync push is done.
There are probably variations to this method, and comments are welcome. For all I know there is a simpler, less painful way to do what I did, but this was the best I could come up with at a time when google held no answers for me.
Enjoy!



Adv Reply

Bookmarks