Extract TAR files over SSH

August 13th, 2008
by jimsander

Instead of copying a large tar file over ssh then extracting, take care of the whole process with one command:

PUSH METHOD:

cat  tarfile | ssh –C user@remotehost “(cd targetdirectory && tar –xf -)”

This will stream the tarfile over a compressed ssl tunnel and the other side will only extract if the target directory exists. The “cd targetdirectory” piece I used as a good prevention to blowing files all over an undesired/unexpected location.

PULL METHOD:

ssh -C user@remotehost”cd sourcedirectory; tar -cvf – dir_or_file> outputfile

This is the opposite method, obviously.  Please note, the output of the SSH needs to be redirected to an output file.

  • Share/Bookmark

Tags: , , , , , , , , , , , , ,
Posted in Non-Tivoli | Comments (1)

One Response to “Extract TAR files over SSH”

  1. jimsander Says:

    Couldn’t agree more. I appreciate the feedback, I’ll look at cleaning it up.

Leave a Reply

  • LinkedIn

    If you want to see my LinkedIn profile, click on this button:

    Jim Sander
  • Save MySQL

JDS Media is Digg proof thanks to caching by WP Super Cache