[Linux] rsync/ssh question

Robert Citek linux@flux.org
Wed, 21 Mar 2007 09:14:25 -0500


Kwan Lowe wrote:
> I'm trying to get the following to work:
> 
> Three machines: HostA, HostB, HostC.  HostC is in a DMZ and can only be accessed via
> SSH from HostB.  I need to transfer directories from HostA to HostC but it cannot
> connect directly.
> 
> I thought about creating a named pipe on HostB and using that as a conduit. I can
> get it to work with tar but not sure how to do so with rsync.
> 
> Is there a way to do this directly with rsync over ssh? Suggestions?

If you can ssh from HostA to HostB and from HostB to HostC, then you can
create an ssh tunnel from HostA to HostC via HostB.

For example, establish an ssh tunnel like so:

$ ssh -2 -N -L 12345:$HostC:22 $UserB@$HostB

After you type in your password, push the tunnel into the background
with Ctrl-Z followed by 'bg'.  Start your rsync:

$ rsync -e "ssh -p 12345" $source $UserC@localhost:$destination_path

That is just one of several ways.

Good luck and please post back letting us know how it went.

Regards,
- Robert