using tar via ssh — for remote file transfers
Having to move large sums of data between boxes is part of an admins life… and sometimes those machines are across the country, and your moving a bunch of sensitive data, and the bosses want to make sure no one can sniff at it… ok, whatever boss
So here’s what I do, use friendly unix tar, and ssh pipe it to another machine.
Lemme show you some examples:
This shows you how to send files FROM the local machine TO a remote machine.
$ cd directory-with-files
$ tar cf - . | ssh username@remoteserver.com “cd /directory-to-put-files; tar xf -” [ENTER]
Ok, you may be asking me to explain this madness:
Change to a directory with files you want to transfer
tar cf - . - create a tar file, with the name “-”, which means output to screen, in the directory “.” (currently in, or right here)
| ssh username@remoteserver - setup an ssh connection to the remote server
“cd /directory-to-put-files; tar xf -” [ENTER] - once connected, change directorys on the local machine, and then EXTRACT that tar file named “-” or output to the screen.
In this case, the output to the screen will be piped thru ssh to the other computer and boom your set.
Now, in order to reverse the logic and transfer FROM a server TO the local machine:
$ cd directory-to-put-files
$ ssh username@remoteserver.com “cd /directory-to-get-files; tar cf - .” | tar xf - [ENTER]
Try it out