Skip to content

Instantly share code, notes, and snippets.

@tirzasrwn
Forked from jtbonhomme/nc.md
Created January 14, 2022 03:37
Show Gist options
  • Save tirzasrwn/45a0faf4b0c7003d9b89493331d5cde2 to your computer and use it in GitHub Desktop.
Save tirzasrwn/45a0faf4b0c7003d9b89493331d5cde2 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/

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