Given two Linux boxes on a LAN, what's the simplest way to transfer files between them?
nfs could be useful.
The Network File System (NFS) allows a client node to perform transparent file access over the network. By using NFS, a client node operates on files residing on a variety of servers and server architectures, and across a variety of operating systems. File access calls on the client (such as read requests) are converted to NFS protocol requests and sent to the server system over the network.
You might require help from your Unix Admin to setup it first time but its very useful.
For doing backups I often use rsync. If I want to backup onto a remote machine I'll put a line in /etc/fstab to keep the remote machine mounted by NFS or CFIS (Samba).
192.168.0.101:/ /mnt/backup nfs rsize=8192,wsize=8192,timeo=14,intr 0 0
Then have a line in my crontab using rsync.
rsync -av /home/user/sourcedir/ /mnt/backup/destinationdir > /home/user/backup.log
netcat is simple but not all versions close connection reliably.
Here is thread about using
socat reliable file transfer over TCP
To sum it up:
Server sending file:
server$ socat -u FILE:test.dat TCP-LISTEN:9876,reuseaddr client$ socat -u TCP:127.0.0.1:9876 OPEN:out.dat,creat
Server receiving file:
server$ socat -u TCP-LISTEN:9876,reuseaddr OPEN:out.txt,creat && cat out.txt client$ socat -u FILE:test.txt TCP:127.0.0.1:9876
OPEN:out.txt,creat,truncwill delete all the bytes in
out.txtbefore writing to it. This option mimics what you'd expect from
cp, and is probably what you want.
OPEN:out.txt,creat,exclwill refuse to write
out.txtif it already exists. Use this option for extra safety.
OPEN:out.txt,creat,appendwill append data to
If you do not have an account (password) on the receiving host you can use woos (web offer one stream):
woos file-or-directory ...
There are a lot of good answers here, and some mention Giver and how it has trouble with large files. A very similar tool which handles large files seamlessly and gzips the transfer is portal.
(NOTE: I wrote this!)
How to use it
Alice wants to send
<file.txt> to Bob, who can be behind the same NAT for direct transfer or anywhere on the internet for relayed transfer. Portal will use direct transfer if it's possible.
Alice initializes the file transfer by executing the following in her shell
$ portal send <folder1> <file.txt>
This outputs a temporary password, which Alice communicates to Bob via some other secure channel.
# the output of the send command, use this password to receive the files > 1-supernova-gamma-ray
Bob executes the following command to receive
$ portal receive 1-supernova-gamma-ray
The file transfer will now begin!
- e2e encryption
- fast gzip (de)compression
- simple protocol aids transfer speed
- handles folders of any sort and depth
- direct communication if ports are open or behind same NAT
- does not do NAT traversal so transfer goes through a relay if direct communication cannot be established
- it's a new tool so it is untried in different systems and might have weird bugs