Easy file transfer with nc(1)
Page 1 of 1

Author:  ibara [ Tue Feb 09, 2016 10:01 pm ]
Post subject:  Easy file transfer with nc(1)

Netcat, aka nc(1), is a great networking tool that does just about anything you can think of.
You can also use it as a quick file transfer client/server. I was getting frustrated that I couldn't get ftp(1) to transfer files off of my LiteBSD QEMU image but then I remembered that this is exactly why I ported nc(1) to LiteBSD.

We know that LiteBSD already has nc(1) but you need to make sure that your server has it (just type 'nc' at a terminal on the server: if it does something then you're good).

You need to setup the server first. The command is:
$ nc -l -p 22222 > file

You can change 22222 to whatever port number you want to use and file to the name you want the received file to have.
The server will now sit patiently and wait until something sends data to port 22222.

Now, on your LiteBSD machine, issue this command:
$ nc hostname 22222 < file

Where hostname is the IP address of the server (if you are on QEMU and want to send a file to the host machine, the hostname is, and file is the name of the file you want to send.

And that's it! nc(1) will quit automatically on both ends once the file transfer is finished.
Remember though that these file transfers are unencrypted, so best to do this on a LAN and not over the open Internet.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group