1

There's a bunch of great tips here regarding using rsync with "proxy" host, but all I found assume there's SSH server everywhere.

What I have is:

  • host A - rsync client, SSH client (Linux), access to B
  • host B - SSH server (Linux), access to C
  • host C - rsync server (it's actually a Windows machine with Deltacopy server)

How should rsync command look so that it opens SSH connection to host B and remote tunnel to host C, from which the files will be taken?

(hope I gave clear explanation of what I need)

0

1 Answer 1

1

I assume the rsync (Deltacopy) server on C listens on the TCP port 873 and you can reach it from B. If so, this becomes the general problem of reaching a TCP port of C from A, when A cannot reach C directly, but can ssh to B which can reach C.

Use local port forwarding:

# on A
ssh -NL 8873:C_seen_from_B:873 userB@B_seen_from_A

Here 8873 is the local port number, quite arbitrary; ssh will listen on this port. I did not use 873 for two reasons:

  1. there may be a local rsync server that has already taken the port;
  2. you most likely are not allowed to use a port with number lower than 1024 anyway.

Now if you connect from A to localhost:8873 then you will reach the port 873 of C. C will see traffic coming in from B. So far there is nothing specific to rsync.

Next invoke rsync on A and wherever in the command you need to specify a LOCATION on C, use the syntax rsync://[USER@]HOST[:PORT]/LOCATION (see "access via rsync daemon" in man 1 rsync), where HOST is localhost and PORT is 8873.

E.g. if on B you would use rsync://C_seen_from_B:873/foo/bar, now on A you should use rsync://localhost:8873/foo/bar.

This way rsync on A will connect to localhost:8873 of A where ssh listens. The connection will be tunneled via SSH and the SSH server on B will connect to C_seen_from_B:873 for you. Ultimately the rsync invoked on A will talk to the rsync (Deltacopy) server running on C.

1
  • Pretty much exactly what I figured out in the meanwhile. A better solution would be to do it in a single command, but I couldn't think of how to do that. Anyway, thanks for the answer!
    – StanTastic
    Commented Nov 26, 2021 at 15:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .