TL;DR Simply squeeze the data through a pipe and you are done:
$ (tar -jc folder) | ssh -C remoteuser@remotesystem 'cd targetfolder && tar -jx'
or the other way around (pull)
$ ssh -C remoteuser@remotesystem 'cd sourcefolderparent && tar -jc folder' | tar -jx
Note: In case you pull to a Mac you might need to adjust the tar -jx
to tar -x -
Lately I had to transfer some files to a remote server. With ssh key already in place not a big deal. Compress and trigger the transfer of the folder locally:
$ tar cjvf package.bz2
$ scp package.bz2 remoteuser@remotesystem
$ rm package.bz2
Log into the remote system and extract the file there:
$ ssh remoteuser@remotesystem
$ tar xjv package.bz2
$ rm package.bz2
Done. But why should I create that temporary garbage? Simply squeeze the data through a pipe and you are done:
$ (tar -jc folder) | ssh -C remoteuser@remotesystem 'cd targetfolder && tar -jx'