Sending file via netcat

On your server (A):

nc -l -p 1234 -q 1 > something.zip < /dev/null
On your "sender client" (B):
cat something.zip | netcat server.ip.here 1234


As a note, if you want to also preserve file permissions, ownership and timestamps, we use tar with netcat to do transfers of directories and files.

On receiving system:

nc -l -p 12345 -q 1 | tar xz -C /path/to/root/of/tree

From sending system:

tar czf - ./directory_tree_to_xfer | nc <host name or IP address of receiving system> 12345 

Hope that helps.


Computer A: nc -l -p 1234 > filename.txt

Computer B: nc server.com 1234 < filename.txt

Should work too ;)

Tags:

Linux

Netcat