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
🌐
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.
🌐
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.
June 11, 2015 -

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.
🌐
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/
Find elsewhere
🌐
Nakkaya
nakkaya.com › 2009 › 04 › 15 › using-netcat-for-file-transfers
Using Netcat for File Transfers
April 15, 2009 - 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 ·
🌐
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.
🌐
GitHub
github.com › MedaiP90 › TarDrop
GitHub - MedaiP90/TarDrop: Use Netcat and TAR to transfer files to hosts in the local network · GitHub
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
🌐
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.
🌐
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
December 28, 2011 - 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/
🌐
Commandlinefu
commandlinefu.com › commands › view › 198 › tar-a-directory-and-send-it-to-netcat
tar a directory and send it to netcat Using tar
February 5, 2009 - 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 ...
🌐
Nnet
nnet.nl › 2016 › 07 › using-netcat-and-tar-to-quickly-transfer-files-between-machines
Using netcat and tar to quickly transfer files between machines – NeuralNet
And on the sending end do: # tar -cf - * | nc otherhost 7000 · It appears that the OpenBSD rewrite of netcat is now in Debian Sid.
🌐
Thejoe
thejoe.it › home › trasferire file di grandi dimensioni velocemente sulla rete con netcat
Transferring large files quickly over the network with Netcat » TheJoe.it
November 22, 2020 - The destination address in my case is 192.168.1.103. The command “tar cf -” It will copy the entire contents of the current directory on the target system and – as already seen – the files are then extracted.
🌐
GitHub
gist.github.com › dc30651558963e791e02
tar and nc · GitHub
tar and nc. GitHub Gist: instantly share code, notes, and snippets.
🌐
David North
dnorth.net › 2019 › 01 › 05 › tar-pipe-with-nc-updated-for-2019
tar pipe with nc, updated for 2019 | David North
January 5, 2019 - Indeed, if you want to shove a load of data between two Windows machines as a one-off, e.g. for a backup, I often find it quickest to boot them both from a Linux live CD / USB stick and use tar pipe (ntfs-3g to mount the disks, naturally). Much easier than trying to persuade file sharing to work properly. ... The addition of v for verbose means you get a print out of files being sent and arriving, giving you a crude approximation of progress and a rough idea of when it's finished. It's also worth noting that the connection provided by netcat is bidirectional (it's just a TCP socket), so you can in fact establish it the other way round (which is handy if the receiving end is e.g.