Why does SCP hang on copying files larger than 1405 bytes?

I’m trying to copy a file from one of my local machines to a remote machine. Copying a file with size upto 1405 bytes works fine. When I try to scp a larger file, the file gets copied but the scp process hangs up and doesn’t exit. I have to hit Ctrl-C to return back to the shell.

I have observed the same behavior with FTP as well. Any ideas about what might be causing this?

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

This definitely sounds like MTU problems (like @Konerak pointed out), this is how I would test this:

ip link set eth0 mtu 1400

This temporarily sets the allowed size for network packets to 1400 on the network interface eth0 (you might need to adjust the name). Your system will then split all packets above this size before sending it on to the network. If this fixes the scp command, you need to find the problem within the network or make this ugly fix permanent 😉

Method 2

Consider that the MTU is typically 1500 B (due to the limitations of ethernet). Of those 1500 B not all are used for ‘data’. So-called protocol overheads take a hefty chunk out of the 1500.

  • SCP (uncompressed) requires a 65 B header.
  • TCP requires a 20-60 B header.
  • IP requires a 20-60 B header.

In light of this, it’s not so surprising that your payload is limited to 1405 B.

P.s. Have a play with wireshark and check the IP headers. Are they allowing packet fragmentation?

Method 3

Sounds like bad hardware to me. If it’s only one machine on the LAN, it might have a bad Ethernet card; if it’s all machines on the LAN, I’d check the hub or router.

Method 4

Sounds like a bad router configuration, data packet transfer limit should be less amount I think

Method 5

There is some kind of tunneling going on between the source and target machines involved. TCP will transmit an MSS when opening the connection (that will be used for ssh/scp), and this tunnels along the way (that add encapsulation, and thus reduce the maximum available MTU) should compensate by transparently modifying said MSS en-route to the destination (and vice versa).

Some tunnel (VPN?) is not doing its job. Or the MSS on your machine is misconfigured.

I am guessing you’ll see the same behavior if you ssh to the machine from which you’re trying to copy, and just do an ls in an empty dir. That should work fine. But if you “cd / ; ls -lR” (and thus get large packets), this will hang as well.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x