Ssh – How to avoid stalled scp transfer when tunneling through a gateway over ssh

file-transferscpsshssh-tunneltunneling

I'm try to transfer a large (1GB+) file from one machine to another, but I have to tunnel through a gateway in between. I'm able to transfer small files just fine. However, with the big file, the transfer stalls mid-way through.

After reading a blog post on the stalling scp transfers, I tried using -l 8192 and even tried lowering it to -l 2000, but that just seemed to make it stall sooner:

scp -l 2000 -v -P 2222 username@localhost:/path/to/file.gz .

From the verbose output (-v) of the scp command, it look like the -l isn't getting passed on…

debug1: Sending command: scp -v -f -- /path/to/file.gz

Any other ideas?

Best Answer

An ugly work around would be to use rsync instead of scp. The rsync program can reliably resume interrupted transfers. If it hangs, just break out with CTRL-C and repeat the command.