Using netcat to copy files between servers

Here’s a real gem posted by tiagofischer here on commandlinefu.com for fast copying of files across a trusted network:


On target: “nc -l 4000 | tar xvf -”
On source: “tar -cf – . | nc target_ip 4000”

Using netcat to copy files between servers. It bypasses encryption overhead of SSH and depending on configuration can be significantly faster. It’s recommended to use only in trusted networks.


I lost track of it once and had a tough time finding it again.


Edit 2014-04-12: For some reason the above isn’t working for me anymore, but this one does:

On target: "nc -l -p 9000 | tar x"
On source: "tar cf - folder | nc other_server 9000"

I found this at this site.

Leave a comment