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
Answer from martinwguy on Stack Exchange
🌐
Screenage
screenage.de › blog › 2007 › 12 › 30 › using-netcat-and-tar-for-network-file-transfer
Using netcat and tar for network file transfer | Screenage
The receiver has to call netcat and tell him to connect to the remote machine and the correct port and redirects the standard output to a file. For convenience he also sets a timeout parameter (-w 10): ... That’s all. You just setup a very fast file transfer.
🌐
Nmap
nmap.org › ncat › guide › ncat-file-transfer.html
File Transfer | Ncat Users' Guide
The above technique works fine for sending a single file. One way to send multiple files is to bundle them up with tar or zip and send the archive file. But there's an even easier way. Just pipe the output of tar directly into Ncat on the sending side, and pipe Ncat's output into tar on the ...
🌐
Djw
toast.djw.org.uk › tarpipe.html
Netcat Tar Pipe
So you have lots of data to transfer between two machines over ethernet. A nice quick and dirty method is to use netcat and tar.
🌐
Nakkaya
nakkaya.com › 2009 › 04 › 15 › using-netcat-for-file-transfers
Using Netcat for File Transfers
tar cfp - /some/dir | compress -c | nc -w 3 [destination] 1234 · A much cooler but less useful use of netcat is, it can transfer an image of the whole hard drive over the wire using a command called dd. On the sender end run, dd if=/dev/hda3 | gzip -9 | nc -l 3333 ·
🌐
Fak3r
fak3r.com › 2007 › 02 › 15 › transfer-files-via-netcat-and-tar
Transfer files via netcat and tar - fak3r
Then, on the source system, have tar pipe out to netcat, that is pointed to the target host/ip: tar -cf - $DIRECTORY | nc $HOST $PORT · Damn, how cool. There’s plenty more info out there, and the more you look the more you’ll realize what you can do with nc.
🌐
Reddit
reddit.com › r/linuxquestions › using netcat with tar to transfer files doesn't finish the process after the file has been transmitted.
r/linuxquestions on Reddit: Using netcat with tar to transfer files doesn't finish the process after the file has been transmitted.
July 8, 2014 -

Basically, a lot of times, I use tar and nc to transfer files over our local network. But when used in this way, the processes don't complete. The file is transmitted, but I have to Ctrl+C on either end to complete it.

On one end, I do tar -czf - ./directory | nc -l -p 3333 and on the other netcat host 3333 | tar -xzf -

Sometimes I put in a pv, to see the speed of transmission. When the file is transmitted, the pipes just hang there, on both ends, showing 0kB/s... But don't end.

I use Arch and the GNU Netcat (I think).

EDIT: Ok, here's what I found out. If I use the OpenBSD Netcat version, it works alright. But the GNU Netcat package doesn't work... So I guess this is a bug in the GNU Netcat? Where should I file it?

EDIT 2: It's NOT a bug. It's a FEATURE. On the GNU Netcat, you have to use the -c switch on the sending side. It makes Netcat close the connection after EOF. (Note: It doesn't matter who's the listener or who's the one that initiates the connection. The side that has the file and sends it needs to use the -c switch.)

And yet again, a mystery solved by myself.

🌐
Medium
medium.com › @tr15t4n › use-tar-and-netcat-to-remote-copy-files-0bacfc3c178d
How to use tar and netcat to remote copy rootfs | Medium
November 27, 2024 - Since tar creates the archive on the fly, it doesn’t matter if out target doesn’t have much storage to spare — as soon as tar packages and zips a small portion of the root directory, it sends it to netcat.
Find elsewhere
🌐
TecMint
tecmint.com › home › linux commands › how to transfer files between two computers using nc and pv commands
How to Transfer Files Between Two Computers using nc and pv Commands
July 13, 2023 - # yum install netcat pv [On RedHat based systems] # dnf install netcat pv [On Fedora 22+ versions] # apt-get install netcat pv [On Debian and its derivatives] Let’s assume that you want to send one large file called CentOS-7-x86_64-DVD-1503.iso from computer A to B over network, the quickest way to achieve this using nc a network utility used to send files over TCP network, pv to monitor the progress of data and tar utility to compress data to improve transfer speed.
🌐
Linux Hint
linuxhint.com › use-netcat-to-transfer-files
Use Netcat to Transfer Files – Linux Hint
tar cfvz - linuxhint2 | netcat -w 2 192.168.1.102 9899 linuxhint2/
🌐
Commandlinefu
commandlinefu.com › commands › view › 198 › tar-a-directory-and-send-it-to-netcat
tar a directory and send it to netcat Using tar
tar cfvz - /home/user | netcat -l -p 10000 - (tar a directory and send it to netcat tar's directory and sends to netcat listening on port 10000 On the client end: netcat [server ip] 10000 | tar xfvz - This will send it over the network and extract it on the clients machine.). The best command ...
🌐
LinuxConfig
linuxconfig.org › home › how to transfer data over the network with nc (netcat) command on linux
How to Transfer Data Over the Network with nc (netcat) Command on Linux
August 19, 2024 - DID YOU KNOW? In addition to transferring files, nc (netcat) can be used for other network-related tasks, such as creating simple chat servers or even port scanning. You can also use nc for transferring directories by compressing them into a single file with tools like tar.
🌐
Pario TechnoBlob
pario.no › 2013 › 07 › 04 › transfer-files-fast-between-servers-using-netcat-and-tar
Transfer files fast between servers using netcat and tar – Pario TechnoBlob
July 4, 2013 - This is a short post on how you can transfer files unsecured but fast between linux servers. I prefer to use netcat (nc) to transfer large amounts of data between servers when I know the connection between them are secure, ie on my private LAN. The sender server should run the following command $ tar cf - folder | netcat 192.168.0.1 9000
🌐
Super User
superuser.com › questions › 372444 › can-i-stop-a-netcat-tar-pipe-and-continue-later-without-overriding-existing-file
ubuntu - Can I stop a netcat tar pipe and continue later without overriding existing files? - Super User
Not automatically, but when you resume the transfer later, you can exclude the files that have already been copied by using a tar exclude list. See http://www.cyberciti.biz/faq/exclude-certain-files-when-creating-a-tarball-using-tar-command/
🌐
Atlantic.Net
atlantic.net › home › blog › how to use netcat to transfer files on linux
How to Use Netcat to Transfer Files on Linux | Atlantic.Net
November 25, 2023 - In this section, we will show you how to transfer and compress the larger file using Netcat. In this example, we will transfer the ubuntu.iso file from one machine to another. On the sender machine from where you want to transfer the ubuntu.iso file, run the following command: ... In the above command, tar is used to compress the file, and the pv command is used to monitor the progress of the file.
🌐
Karnsonline
karnsonline.com › netcat-tar-pipe
Netcat Tar Pipe
April 12, 2022 - cd /path/to/source/directory tar -cf - * | ncat <hostname_of_receiver> 7000 · Synology NAS's do not have netcat installed by default and you will need to install the DiagnosisTool to get access to the binary.
🌐
GitHub
github.com › MedaiP90 › TarDrop
GitHub - MedaiP90/TarDrop: Use Netcat and TAR to transfer files to hosts in the local network
Under the hood TarDrop implements the mechanism of file transfer via tar + netcat and combines it with auto-discovery of other hosts on the local network.
Author   MedaiP90