Send File Across Network
On Linux, there’s almost always more than one way to do anything. Sending a file across from one Linux server to no different.
NetCat
First, with NetCat. The receiver is the TCP listener.
On the receiving end:
nc -l 9000 > newfile.txt
On the sending end:
cat myfile.txt | nc -w 2 myserver 9000
Python web server
Python has a built-in HTTP server module that can be used to host files, and curl or wget can be used to download files. The sender is the TCP listener.
On the sending end:
python -m http.server 9001
On the receiving end:
curl -OL http://myserver:9001/thefile.txt
SCP
SCP is a commonly used tool.
To send:
scp myfile.txt remoteuser@remoteserver:/tmp/myfilecopy.txt
To receive:
scp remoteuser@remoteserver:/tmp/theirfilecopy.txt theirfile.txt
SSH
To use SSH without SCP:
To send:
cat myfile | ssh remoteuser@remoteserver 'cat > myfilecopy.txt'
To receive:
ssh remoteuser@remoteserver 'cat /tmp/theirfile.txt' > theirfilecopy.txt
Other
rsync that can also be used to copy files over the network.
To export a file through NFS, put the directory name in the /etc/exports file and reload the NFS server. Then, mount the directory through NFS and copy the file. Samba can be used instead of NFS when sharing files with Windows systems. Directories can also be mounted using SSHFS (SSHFS is also available for Windows).