Skip to content

Instantly share code, notes, and snippets.

@jtbonhomme
Last active November 7, 2024 18:27
Show Gist options
  • Save jtbonhomme/50e381f053f6cd0acdb8 to your computer and use it in GitHub Desktop.
Save jtbonhomme/50e381f053f6cd0acdb8 to your computer and use it in GitHub Desktop.
Using Netcat for File Transfers

Netcat is like a swiss army knife for geeks. It can be used for just about anything involving TCP or UDP. One of its most practical uses is to transfer files. Non *nix people usually don't have SSH setup, and it is much faster to transfer stuff with netcat then setup SSH. netcat is just a single executable, and works across all platforms (Windows,Mac OS X, Linux).

Destination

On the receiving (destination) terminal, run:

nc -l -p 1234 > out.file 

For mac users, use

nc -l 1234 > out.file

This will begin listening incomming data on port 1234.

Origin

On the sending terminal, run:

nc -w 3 [destination ip address] 1234 < out.file

will connect to the receiver and begin sending file. The -w 3 option stands for a 3 seconds timeout.

Blog source

http://nakkaya.com/2009/04/15/using-netcat-for-file-transfers/

@Darkcast
Copy link

Darkcast commented Jan 4, 2021

what if you want to tranfer multiple files and you the filesystem is write protected how can one download all the file recursively ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment