Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm occasionally downloading a very large file via scp and there's a small chance each time of the connection dropping and cutting the transfer mid-way.

Is there a way to resume it?

share|improve this question
up vote 2 down vote accepted

You can try the following approch: instead of scp use dd to skip over the downloaded part and append it to the file.

sofar=`ls -l ./destfile | awk '{print $5}'`
ssh rsys "dd if=./srcfile bs=1 skip=$sofar" >> ./destfile

Possible optimization: work with big blocks. Let's leave this as a homework.

share|improve this answer
I haven't tested this yet, but am accepting the answer tentatively since using dd sounds like a great approach for solution. – GJ. May 10 '12 at 12:19
I just tested it, works perfectly, thank you! – Kossak Aug 23 '15 at 18:38
@Kossak, nice to hear! – yarek Aug 23 '15 at 18:42

With scp, no.

If both ends have it, you can use rsync -LvzP remoteserver:path/to/file localfile to transfer a single file.

share|improve this answer

The short answer is no, this is not possible with scp. Yarek and Grawity have provided valid solutions that I would +1 to both, but my preference for flexibility is rsync. I would also add however, that the example commands provided both assume you are retrieving a file from a remote server to your local workstation. Please keep in mind that the final two parameters should be considered source_file and target_file in that order. The syntax of the filename varies based on whether it is local or remote. If I were sending [text] files, I would rewrite these as:

#From local to remote
sofar=`ssh remote_system ls -l interrupted_file | awk '{print $5}'`;
dd if=source_file bs=1 skip=$sofar | ssh remote_system "cat >> ./interrupted_file"

And to the rsync solution, I add -e ssh. You should consider whether or not you need verbosity, compression, preserve ownership, permissions, timestamp, recurse directories, etc. Check man pages and google, regarding the -L parameter. You might want symlinks to remain as links instead of referencing them.

rsync -P -e ssh local_source_file remoteserver:path/to/interrupted_target_file

share|improve this answer
scp -o ConnectTimeout 60

Lets you specify the timeout for a connection. May keep your connection from breaking up.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.