Why does scp get stalled? How do I resolve it?

139,937

Solution 1

This happens because scp is trying to grab as much bandwidth as possible, and any delay (by a firewall, etc.) can stall it. Limiting the bandwidth (with -l option) will fix it.

For example, you might want to limit the bandwidth to 1 MB/s (= 8192 Kbits/s):

 scp -l 8192 <file> <destination>

Source: http://www.aixmind.com/?p=1371 - Wayback Machine

Solution 2

I've managed to solve it by using rsync:

rsync -avz -e "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" --progress /tmp/bigfile.txt [email protected]:/tmp/

Solution 3

Any chance you're behind a Cisco ASA firewall? If so, turn off "sequence number randomization" and that'll help a lot -- also disable TCP Offload (ethtool -K $INTERFACE tso off gso off gro off) if you're on a Cisco ASA with Broadcom NICs in your server.

Solution 4

Given the error message that we received when the scp stalled I suspected that it was the encryption that was failing. "The authenticity of host 'myserver (10.10.11.12)' can't be established. ECDSA key fingerprint is SHA256:+zkyskXlxVQ0kRorLW26pzprIYbsM4N3hbaDLz1RNpo" With that in mind I ran "scp -c aes128-ctr /tmp/test.dan/bigfile.src myserver:/tmp/bigfile". scp WAS successful with the alternate cipher. Is there an issue with the default cipher blowing a buffer space?

Might try adding "-c " with an alternate cipher and see if it resolves your stall.

Share:
139,937

Related videos on Youtube

Lelouch Lamperouge
Author by

Lelouch Lamperouge

I am a Graduate Student in Computer Science.

Updated on September 18, 2022

Comments

  • Lelouch Lamperouge
    Lelouch Lamperouge over 1 year

    When I attempted to copy a file (of size, ) over the network using scp I get a error <file> stalled Why does this happen? How do I resolve it?

    • Hatshepsut
      Hatshepsut over 6 years
      I like rclone for this; I've never had any problems with it.
    • kilojoules
      kilojoules over 5 years
      I canceled and restarted the scp command and the problem went away for me
  • elmicha
    elmicha over 12 years
    Thank you for your answer and the link to the source. But I think your source says that -l 8192 means 8192 Kbit/second, and the -l might work up to 1 Mbit/second (which seems to be a bit outdated nowadays).
  • Lelouch Lamperouge
    Lelouch Lamperouge over 12 years
    @elmicha 8192Kb==1MB
  • elmicha
    elmicha over 12 years
    @Eknath Oops, you're right.
  • Erwin Wessels
    Erwin Wessels over 10 years
    Just to clarify: the example limits scp's bandwidth to 8192 Kbit/second. The source article's author suggests that this number should work fine for connections of upto 1 Mbit/second.
  • Saurabh
    Saurabh over 7 years
    Worked like a charm :)
  • Melebius
    Melebius over 7 years
    @LelouchLamperouge 8192Kb==1MB Not really, 8192 Kbit is 1 kiB!
  • mjaggard
    mjaggard almost 7 years
    That's genius. Is that change permanent or do I need to put the command somewhere? Just to be clear, you have to set that on your NIC, not on the cscotun interface.