Submitted by any2xml on Sun, 06/06/2004 - 00:02.
"Just google on netcat and dd " said my son, when I asked him how to ghost my linux box across the network. He would not tell me more :-) So I read the excellent doco on netcat but still did not get how to combine it with dd to ghost. So I ran netcat in two windows to test it... In one window I ran the listener:
cd /tmp
/usr/bin/netcat -l -p 1234 | uncompress -c | tar xvfp -
In the other:
tar cfp - *.pl | gzip  -c | /usr/bin/netcat -w 3 localhost 1234
Worked like a charm. I can pipe the output of netcat to a script to do virtually anything I want. Hmm what do I need dd for?

Yet Another LinxApachePerlMySQL bigot

Be secure
Posted by dustin on Wed, 06/09/2004 - 13:09.

We do something similar, but we pipe it through an SSH connection. Even on a local network, it's a little scary to open a network port to a program as powerful as tar without any authentication or encryption. Here's what it looks like:

cd /tmp && tar -czf - dir_to_copy/ | ssh dest_host tar -C /var/tmp -xzf -

This copies dir_to_copy from /tmp on the source host to /var/tmp on the destination host. Note that you need GNU tar to use the -C option.. on our Solaris boxes, we have to specify it explicitly. You could certainly put 'dd' in the pipeline somewhere, but the network buffers are pretty good on their own, so I wouldn't bother.

Thanks to Nick Russo for this tip.

Comment viewing options
Select your preferred way to display the comments and click 'Save settings' to activate your changes.