in Technology

Transfer directories between computers using SSH and tar

When I need to transfer lots of files or directories between computers, I usually use tar and ssh together. Last time I used it however, I realized that perhaps not everyone knows how to do this.

The procedure is very simple, and a full command could look something like this:

tar -cf – directory/ | ssh tar -xf – -C /destination/

Simple huh? If you want compression, just add z for gzip or j for bzip2 to both tar statements. This could be necessary if you are planning to do this over slow lines.