Copying directories and files between computers using tar

The following shows a number of solutions for using tar to copy a local directory structure and files or just the directory structure to a remote computer, optionally unpacking at the far end.

copy a local directory tree and files to remote system over ssh and leave it in a tar file

> cd source-directory
> tar -cvf - . | ssh username@remote-host "(cd directory && cat - > tmp.tar )"
username@remote-host's password:

copy a local directory tree and files to remote system over ssh, unpacking the result

> cd source-directory
> tar -cvf - . | ssh username@remote-host "(cd directory && tar -xvf - )"
username@remote-host's password: