Sending files on a shoestring

Ditch your fancy cloud storage and share files using simple Unix tools.

This is a short post detailing a nifty way to send files over a network using simple Linux tools. Be warned, this is in no way secure, and shouldn't be used to send sensitive files over networks that you can't wholly trust!

Setting up the receiver

nc -l 49152 | tar zxv

The receiver will listen on the specified port, and extract the incoming files into the current working directory. Note that port 49152 is an ephemeral port and will likely be open, but in rare instances that this is not the case, you and the sender may need to negotiate a different one.

Sending files

tar zcf - <path> | nc -q <host> 49152

-q is dependant on the Netcat implementation

The sender essentially performs the same steps, but in reverse. The target path will be packed into a single archive, and streamed over the network to the given host.

Whilst sending files this way is entirely open to abuse in the wild, it can be really useful when sending files to colleagues on the same network, avoiding the rigmarole of setting up temporary SSH access, or creating shared folders.