Very often I find myself having to transfer files to remote machines that do not have ftp or sftp server running.
Here are a few methods that I use in those cases:
- Using scp:
The secure copy protocol and command are part of ssh. I am assuming that you have Linux or Unix boxes that you are dealing with. If any of them are Windows computers you need to install ssh servers and clients respectively.
The command looks like this:
scp source_file user@IP:path
For example, if I wanted to copy the 1.txt file to the /tmp directory on the remote computer with ip address of 18.104.22.168 as root, I would do:
scp 1.txt firstname.lastname@example.org:/tmp/
- Using ssh:
cat source_file | ssh user@IP -c ‘cd /target_dir ; cat > target_file’
For example if I wanted to transfer my local file 1.txt to the same remote host and save it in the /tmp directory under the name of 2.txt, I would do:
cat 1.txt | ssh email@example.com -c ‘cd /tmp ; cat > 2.txt’
- Using netcat:
First you need to start a netcat server on your local machine to serve the files:
cat source_file | nc -l port_number
Then on the computer receiving the file you do:
nc IP port_number > target_file
For example, if I wanted to send the same file 1.txt to the same remote computer and save it as 2.txt over port 3030 (you can chose any port, but make sure it is over 1024), I would do:
On the local computer:
cat 1.txt | nc -l 3030
On the remote computer, receive the file by specifying the IP address of the machine sending the file:
nc 22.214.171.124 3030 > 2.txt
Again, note here that the ip address specified is of the computer sending the file (unlike the previous examples with scp and ssh).