Tar through ssh
February 22, 2007I love this command, which I’ve stolen from an article titled “Tar through ssh” by Graeme Winter on linux.com:
To transfer a (large, complicated) file tree from one machine to another, using stuff which is usually supported:
tar cf - stuff | ssh bob@wendy.no.where.com tar xf - -C /home/brian
Autopsy:
(tar cf - stuff) - tar stuff to the standard output
(| ssh bob@wendy.no.where.com) - pipe this to an ssh connection to wendy - where
(tar xf - -C /home/brian) - is run - which will untar the standard input and place the result in /home/brian….
Neat. This is better than using scp -r or tar then scp, because you can send > 4 gig files, and also retain softlinks etc which get broken by scp…
Or, to go the other way:
ssh bob@wendy.no.where.com tar cf - /path/to/stuff | tar xf - -C /final/destination