Thursday, April 10, 2014

using netcat


in unix-master:/STORE I'm copying in all the configs that I think we will need when setting up the clones


the idea being:

cloned base operating system + altered config from /STORE == new system


meaning to say that hopefully everything required to replicate the services will actually be on unix-master:/STORE and the base operating system should
contain all the software we need .. if not tell me, and i'll add it to the master


well, that's the theory, I should have thought of it sooner before we started making too many clones


basic recipe to do this is on UNIX-MASTER

unix-master:/STORE # mkdir WAL

unix-master:/STORE/WAL # nc6 -l -p 6666 | tar xvpf -



and then on the system you want the important bits from eg.

wal:/ # gtar cf - etc/. usr/local/etc/. web/server/etc/. web/server64/etc/. | nc6 -x unix-master 6666


there are probably other directories to copy


NOTE WELL:

you NEED to be in the ROOT directory and you most certainly NEED to put things like

web/server/etc/.

instead of, say

web/server/etc

as the latter example will *ONLY* copy the symlink eg. in this case

wal:/ 18851 # dir /web/server/etc
lrwxrwxrwx 1 root root 21 Dec 15 2006 /web/server/etc -> /global/u1/etc/server/

so USE the trailing slash plus the dot /. as that will make sure the contents of the directory are copied regardless of whether it is a symlink


EXAMPLE 1

using BELUGA as a receiver and NARWHAL as the sender, CAT a file from one machine to another


a. set up the remote listener

 beluga:~/INCOMING # nc6 -l -p 9876 > newname.tar

"-l" says LISTEN
"-p port" is the port to listen on


b. netcat the file from the sending machine

 narwhal:~ #  nc6 -x beluga 9876 < dot.tar

"-x" makes it hang up after the transfer is done, ie. close down the receiver once the sender is done


c. use your file!

 beluga:~/INCOMING # tar tf newname.tar | wc
      27      27     307

ps. this will work with any arbitrary file, I used a .tar file simply to demonstrate that the file transferred properly in this example by running
through tar itself to verfiy that it was good, it is probably prudent to verify that your file transferred properly - "cksum" could help with that

 narwhal:~ # cksum dot.tar
 3708157944      1505280 dot.tar

 beluga:~/INCOMING # cksum newname.tar
 3708157944      1505280 newname.tar





EXAMPLE 2

using BELUGA as a receiver and NARWHAL as the sender, TAR a directory from one machine to another



a. make a new directory for your incoming tar explosion

 beluga:~ # mkdir INCOMING


b. set up the receiving end with a gtar

 beluga:~/INCOMING # nc6 -l -p 9876 | gtar xvf -


c. send your tarred up directory

 narwhal:~ # gtar cf - . |  nc6 -x beluga 9876


the "-x" says transfer the file then hang up


d. now use your files!

beluga:~/INCOMING 25260 # nc6 -l -p 9876 | gtar xvf -
nc6: using stream socket
./
./.lesshst
./.vimrc
./nc6-1.0/
./nc6-1.0/CREDITS
./nc6-1.0/bootstrap
./nc6-1.0/aclocal.m4
./nc6-1.0/intl/
./nc6-1.0/intl/dcngettext.o
./nc6-1.0/intl/osdep.c
./nc6-1.0/intl/ngettext.c
./nc6-1.0/intl/gettext.o
....snip....
./.aliases
./.cvsrc
./.netrc
./.epltidyrc
./dot.tar




just from basic testing, this would seem to be about 20% faster than doing an "scp -c blowfish"

No comments:

Post a Comment