Pipe Directories Over SSH

My good friend Jayk showed me this nifty trick years ago for moving directories over ssh:

From a local directory to a remote directory:

tar -zcf - . | ssh name@host "tar -zvxf - -C <destination directory>"

From a remote directory to a local directory:

ssh name@host "tar -zcf - -C <source directory> ." | tar -zvxf - 

This works by causing tar to read from stdin or write to stdout “-f -” and piping the results through ssh using the ‘execute command over ssh’.

This entry was posted in friends, unix. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>