0

I want to rsync a directory from a server to my client. I cannot access the server directly, but need to hop through an ssh gateway. From my '.ssh/config':

Host gw
    User ab123456
    HostName gw.somewhere.ac.uk
    IdentityFile ~/.ssh/id_dsa.pub
    ServerAliveInterval 60

Host remote
    User me
    HostName remote.somewhere.ac.uk
    IdentityFile ~/.ssh/id_dsa.pub
    ProxyCommand nohup ssh gw netcat -w1 %h %p
    ServerAliveInterval 60

It works fine for interactive ssh sessions, but rsync fails. Sometimes immediately, sometimes after a few seconds, always before copying any files:

$ rsync -av remote:/path/to/somewhere/ somewhere/
nohup: redirecting stderr to stdout
rsync: connection unexpectedly closed (0 bytes received so far) [Receiver]
rsync error: unexplained error (code 255) at io.c(226) [Receiver=3.1.0]

$ rsync -av remote:/path/to/somewhere/ somewhere/
nohup: redirecting stderr to stdout

            Access to this system is monitored etc. etc.

receiving incremental file list
Write failed: Broken pipe
rsync: connection unexpectedly closed (12288 bytes received so far) [receiver]
rsync error: error in rsync protocol data stream (code 12) at io.c(226) [receiver=3.1.0]
rsync: connection unexpectedly closed (16336 bytes received so far) [generator]
rsync error: unexplained error (code 255) at io.c(226) [generator=3.1.0]

I suppose this problem is related to the netcat gateway through machine gw. How can I use rsync correctly when I need to use a multi-hop connection?

I'm using netcat because my colleague gave me this configuration file, and it works for normal ssh.

Note that unlike the situation in this question, I experience the same problem when I replace rsync -av with scp -pr (and I do need rsyncs ability to synchronise properly).

gerrit
  • 3,457
  • 6
  • 25
  • 41

1 Answers1

1

I could get it to work by replacing

#ProxyCommand nohup ssh gw netcat -w1 %h %p

with

ProxyCommand nohup ssh gw -W %h:%p

which works for modern OpenSSH. Now I'm not getting an immediate timeout.

gerrit
  • 3,457
  • 6
  • 25
  • 41