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 frequently transfer large directories over scp and it would be sweet if I could somehow compress the directory, send it, and decompress it all in one.

Is something like this possible?

share|improve this question
up vote 21 down vote accepted

How about using rsync instead with the -z option enabled for compression?

rsync -az --progress source_dir/* remote_host:/destination_dir

This also has the added benefit that if the file already exists and has not changed on the destination, it will not be transferred.

share|improve this answer
I like you. +1. – Varun Vohra Oct 2 '12 at 17:02

Thanks to @johnshen64's answer, I was able to come up with something quite nice

tar -zc path/to/source | ssh user@remote tar -zxC path/to/destination

Unfortunately, this doesn't show progress as it transfers. I have noticed incredible speed improvements using this method.

If anyone know how to show progress for a transfer like this, I'd greatly appreciate the help :)

share|improve this answer
Insert pv between tar and ssh. – grawity May 7 '12 at 18:38
This is great if you don't have rsync available – Simon Hartcher Sep 29 '13 at 0:50

well, i would use tar instead

tar cf - directory | ssh server 'tar xf -'

you can add v to verify.

zip should be the same, but tar is more robust for linux in my opinion.

share|improve this answer
+1 thanks for your help; this got me half way there. I was able to come up with a solution that doesn't use the cryptic - character, also uses gzip compression and allows to target a destination directory. – macek May 7 '12 at 17:50
@macek: Note that f - might be required on other operating systems, since most tar versions will try to read from a tape drive otherwise. Reading from stdin by default is GNU-specific. – grawity May 7 '12 at 18:39

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.