4

I am a happy user of rsync -e ssh and use it to synchronize data between my machine and a remote host using

rsync -avz -e ssh me@hostA:~/folder ~/folder

And this did what I needed until now.

I am now working with a configuration where the access is a bit more complicated. Suppose now ~/folder is on hostB, but hostB is not directly accessible from my machine, but only indirectly via hostA.

So if I only want to see the folder on hostB. I first need to ssh to hostA, then to hostB after which I can see my files in ~/folder on the remote host.

My question now is, what is the (best) method to use rsync directly between my machine and hostB?

Unfortunately this is the configuration I need to work with. Assume there is no possibility to temporarily store the data on hostA itself.

8

Have a look at How do I connect to a pc through another pc using ssh

You create a new ~/.ssh/config entry with the name tunnelb:

Host tunnelb
HostName hostB
User user
ProxyCommand ssh user@hostA nc %h %p

If you have a recent version of ssh you can use Proxycommand ssh user@hostA -W %h:%p instead. This is preferred as it does not rely on nc

Now you can just use rsync -e ssh tunnelb:~/folder ~/folder as it will use the defined entry in ~/.ssh/config.

0

Variant 1:

First, start ssh on hostA permanently with local port forwarding in another terminal. E.g.:

ssh -N -v -L 22022:hostB:22 hostA

Then, "feed" rsync with ssh to localhost:22022. One variant is to write to ~/.ssh/config:

Host hostB
HostName localhost
Port 22022

Variant 2:

Replace -e ssh with -e to some script which contains:

ssh hostA 'ssh hostB' "$@"

I didn't try it so some details would be elaborated additionally.

  • Thanks for your hint. Was not able to successfully rsync yet. For the portforwarding I get an errormessage like debug1: Unspecified GSS failure. Minor code may provide more information Credentials cache file '/tmp/krb5cc_1000' not found. For the second variant I get bash: hostA: command not found. I will puzzle a bit on you suggestion, any more hints more than welcome – Bernhard Jul 15 '12 at 9:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.