Broken pipe error on scp

26,031

Solution 1

Try throttling - 2Mb/sec max throughput like so:

scp -l 2000 MaryBaked.tar.gz [email protected]:/home/marybakedpdx

scp man page

Solution 2

The problem is that the connection closed, probably because the file is too big and the session is terminated by timeout.

Solution 1: Sending back and forth keep alive messages from the server (acks) which keeps the session, Using ServerAliveCountMax and ServerAliveInterval options

scp -o ServerAliveInterval=15 -o ServerAliveCountMax=3 <yourIP>:~

In this example, every 15 seconds looking back for acks and if 3 acks in 45 seconds (15*3) not coming back close the session.

Look at the properties documentation below :

ServerAliveCountMax Sets the number of server alive messages (see below) which may be sent without ssh(1) receiving any messages back from the server. If this threshold is reached while server alive messages are being sent, ssh will disconnect from the server, terminating the session. It is important to note that the use of server alive messages is very different from TCPKeepAlive (below). The server alive messages are sent through the encrypted channel and therefore will not be spoofable. The TCP keepalive option enabled by TCPKeepAlive is spoofable. The server alive mechanism is valuable when the client or server depend on knowing when a connection has become unresponsive. The default value is 3. If, for example, ServerAliveInterval (see below) is set to 15 and ServerAliveCountMax is left at the default, if the server becomes unresponsive, ssh will disconnect after approximately 45 seconds.

ServerAliveInterval Sets a timeout interval in seconds after which if no data has been received from the server, ssh(1) will send a message through the encrypted channel to request a response from the server. The default is 0, indicating that these messages will not be sent to the server.

Solution 2: I can suggest you a simple workaround: compress the file , send it and extract it in your destination machine. This will short the connection time and should fix the timeout issue.

gzip bigfile.bin
scp bigfile.bin.gz <destinationIp>:~/
ssh -At <destinationIp>
cd ~
gunzip bigfile.bin.gz
Share:
26,031
redress
Author by

redress

ML/AI

Updated on July 09, 2022

Comments

  • redress
    redress almost 2 years

    I can ssh into my ubuntu box just fine, and I have already scp'd a version of my app onto the server, but when I run

    scp MaryBaked.tar.gz [email protected]:/home/marybakedpdx

    or even

    scp MaryBaked.tar.gz [email protected]:~

    The progress of the scp jumps up to 81%, then the process says stalled and I get

    rite failed: Broken pipe lost connection

    EDIT

    root@marybakedpdx:/home/marybakedpdx# df -T

    Filesystem     Type     1K-blocks    Used Available Use% Mounted on
    /dev/vda1      ext4      30830588 2906508  26334944  10% /
    none           tmpfs            4       0         4   0% /sys/fs/cgroup
    udev           devtmpfs    498088       4    498084   1% /dev
    tmpfs          tmpfs       101788     356    101432   1% /run
    none           tmpfs         5120       0      5120   0% /run/lock
    none           tmpfs       508940       0    508940   0% /run/shm
    none           tmpfs       102400       0    102400   0% /run/user