Sending file via netcat

Solution 1:

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

Solution 2:

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.

Solution 3:

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

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

Should work too ;)

Solution 4:

Init the target listening to the port. AKA receiver end

nc -vl 44444 > pick_desired_name_for_received_file

Send the file to the target. AKA sender end

nc -n TargetIP 44444 < /path/to/file/you/want/to/send

read more https://www.maketecheasier.com/netcat-transfer-files-between-linux-computers/ https://gist.github.com/A1vinSmith/78786df7899a840ec43c5ddecb6a4740