Pipe tar file to remote server w/ ssh
jesterj@jesterj-laptop:~$ tar zcvf - donkey* | ssh jesterj@donkey.dnsdojo.com “cat > ~/testarchive3.tar”By far the easiest way to tar a file and send it to a remote location is to simply have two commands on one line. The first to create the tar file, the other to scp the command. In this example, I am not prompted for a passphrase since i have my ssh key saved on the remote server for this user.
Easy:
jesterj@jesterj-laptop:~$ tar -cvf testarchive.tar donkey*; scp testarchive.tar jesterj@remoteserver:~
donkey
donkey1.zip
donkey2.txt
donkey2.zip
donkey.tar
donkey.txt
testarchive.tar 100% 20KB 20.0KB/s 00:00
jesterj@jesterj-laptop:~$
Pipe the file…More complicated:
jesterj@jesterj-laptop:~$ tar zcvf - donkey* | ssh jesterj@donkey.dnsdojo.com "cat > ~/testarchive3.tar"
source: http://www.cyberciti.biz/faq/howto-use-tar-command-through-network-over-ssh-session/