I copied this from http://happygiraffe.net/copy-net which is a nice little tutorial for remote copying of files.
tar is normally an archiving program for backups. But with the use of ssh, it can be coerced into copying large directory trees with ease. It has the advantage that it copies things correctly, even ACLs on those Unixes which have them, as well as being perfectly comfortable with symlinks. The syntax, however, is slightly baroque:
tar -cf - /some/file | ssh host.name tar -xf - -C /some/place/cool Whilst it looks complex, at heart it's quite simple: create a tar archive to stdout, send it across the network to another tar on the remote machine for unpacking.
The arguments to the first tar are -c to create a new archive and -f -, which tells tar to send the newly created archive to stdout.
The arguments to the second tar command are the reverse: -x to extract the archive and -f - to take the archive from stdin. The final -C /destination tells tar to change into the /destination directory before extracting anything.
Why should you use this method when the other two are available? For initial copying of large directory trees, this method can be very quick, because it streams. The first tar will send it's output as soon as it has found the first file in the source directory tree, and that will be extracted almost immediately afterwards by the 2nd tar. Meanwhile, the first tar is still finding and transmitting files. This pipeline works very well.
As with the other two methods, you can ask for compression of the data stream if your source data is amenable to it. Here, you have to add a -z flag to each tar:
tar -czf - /some/file | ssh host.name tar -xzf - -C /some/place/cool In a similiar fashion, you can enable verbose mode by passing a -v flag to the 2nd tar. Don't pass it to the first one as well, or you'll get doubled output!
Why shouldn't you use this method?
The syntax is a pain to remember. It's not as quick to type as the scp command, for small amounts of files. rsync will beat it hands down for a tree of files that already exists on the destination.
On Sep 26, 2007, at 3:15 PM, ann kok wrote:
Hi all
Can I use ssh to have remote tar files from machine A to machine B?
ssh from machine A to machine B tar all files in machine B to exact to machine A
Thank you
Got a little couch potato? Check out fun summer activities for kids. http://search.yahoo.com/search?fr=oni_on_mail&p=summer+activities +for+kids&cs=bz _______________________________________________ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos