For clarity of instructions, we will use the following terminology.
Server = Remote system, typically like a web server
Client = Local system, the computer/vm you are using
Download file from Server
Run the following command on the server.
cat file.txt | nc -l -p 1234
Now on the client we can download the file with the following. Change the IP to the Server IP address
nc 192.168.1.20 1234 > file.txt
Upload from Client to Server
If we want to reverse this, aka. send a file from the client to the server, we can do the following
This will write the file to file.txt
nc -l -p1234 -q 1 > file.txt < /dev/null
Send file.txt to 192.168.1.20. Change the file and IP address as needed.
cat file.txt | nc 192.168.1.20 1234