47

There is a certain ubuntu 10.04 server where if I ssh a file onto it from any server that is outside the office where this server is (meaning any of use scp-ing onto this server through LAN from within this server always works for some reason), then scp-ing fails for any file over 2112 kB in size, and is stuck at 2112 kB. So

scp -vvv /home/attila-szeremi/aszeremi.tar.gz  attila@server.hu:~/aszeremi.tar.gz

shows something like 1% 2112KB 909.2KB/s - stalled - dynamically at the end, where the KB/s becomes lower and lower.

Does anyone know what may be causing this and how I can fix it?

What I have tried so far:

  • Limiting the speed with scp -l 2000. It just made the file sending slower, and at 2112 kB it got stuck again.
  • Enabling compresison with -C. It was still stalled at the same size.
Attila Szeremi
  • 5,235
  • 5
  • 40
  • 64
  • Check that the destination has room for the whole file. – Thor Aug 16 '12 at 10:48
  • Same problem. None of the [answers](http://linuxsecure.blogspot.com.es/2008/05/scp-stalled-through-firewall-ssh-no.html) helped me. I switched to `rsync` and the problem went away. Not a solution but a decent workaround im my case. – con-f-use Apr 13 '15 at 11:50
  • 1
    We have also found that incorrectly configured tcp intercept on a router between the sender and receiver can also stall at 2112KB. – smokecatcher Jun 19 '18 at 10:20

5 Answers5

34

I seemed to have found the fix. I had to set the LAN card's mtu setting to 1492 by:

# ifconfig eth0 mtu 1492
Attila Szeremi
  • 5,235
  • 5
  • 40
  • 64
  • Thank you! This solves the SCP stalling issue I had with copying files to a CentOS 6.4 VM. Transfers would stall at the same 2112 KB point. – davidjb Mar 18 '14 at 05:50
  • 1
    Here it is 2014, running latest Debian, fresh install and this is still a problem on my PC? Thanks for the fix. Any idea why it is not 1492 out of the box? – sleeves Oct 03 '14 at 09:14
34

The only way I managed to get rid of this problem was by disabling TCP SACK:

$ sudo sysctl -w net.ipv4.tcp_sack=0
dav.garcia
  • 546
  • 8
  • 13
  • 2
    Works on Ubuntu 14.04 as well. Changing the MTU or limiting the speed had not helped. After disabling SACK, I was able to go back to an unlimited speed without any problems. This should be the answer. – The_Rafi Mar 10 '16 at 23:30
  • i get the error: unknown oid 'net.ipv4.tcp_sack=0' on mac – fire in the hole May 19 '17 at 08:45
13

On newer Linux systems the ifconfig command may have been replaced by ip

The command to set the mtu becomes:

# ip link set dev eth0 mtu 1492
kriss
  • 23,497
  • 17
  • 97
  • 116
2

I got stuck with the same on a Mac OS X and @dav.garcia's answer did it for me with a small change:

  $ sudo sysctl -w net.inet.tcp.sack=0
vinitius
  • 3,212
  • 2
  • 17
  • 22
0

I was seeing this same problem. None of the above suggestions worked for me, but they got me on the right path. I was behind a firewall with the MTU setting set to 1300. Setting my LAN card's MTU to really low (576, somewhat random) caused my packets to stop being dropped.

$ sudo ifconfig eno1 mtu 576

I had to do this on each of my Linux clients. For some reason, the windows machine on the same subnet didn't have a problem.

Ben Jensen
  • 41
  • 4