Fast file transfers with rcp

If you are using a Linux (or Unix) machine, you are commonly advised to use the Secure Copy (scp) program for transferring files between machines. This program uses the Secure Shell (ssh) to transfer files in an encrypted format. Any person trying to intercept the traffic by capturing packets between the two machines is not able to decipher the transferred contents.

So far so good. However, there is one side-effect of using encryption for file transfer; it is slow. For example, you could try this yourself. Set up two machines that will be transferring files over the network. Transfer a large file (typically 1 GB or more) between the two machines using scp. Now set up a web server on one of the machines and make the large file available for download. From the second machine, use wget to download the large file. It is very likely that the download speed was significantly higher in the case of using a web server, than in the case of scp. (As a matter of clarification, when sensitive files are being transferred, the use of scp is recommended. However, not all files qualify for this requirement.)

Before the days of scp, there was the rcp. Just like ssh has become the recommended remote login program over telnet, scp is now favoured instead of rcp. However, in case the communication between the two machines happens over a trusted network (like a private LAN), it may be safe to use rcp for the file transfer.

If you try using rcp without any preparation, then you will encounter a Permission denied error that does not give any further information regarding the actual problem. Some background preparation is necessary before this transfer will be allowed.

  • Install the rsh-server and xinetd packages, as required. Depending on your Linux distribution, this might be available in a DVD or on-line repository.
  • Configure the rsh and rlogin services to be started by running the commands:
    [root@linuxbox ~]# chkconfig rsh on
    [root@linuxbox ~]# chkconfig rlogin on
    [root@linuxbox ~]# service xinetd restart
  • If required, allow the traffic on TCP ports 513 and 514. (During testing between two machines within a private LAN, it may be okay to disable the firewall temporarily.
  • Add rsh, rlogin, and rexec as entries in the /etc/securetty file.
  • In the user’s home directory of the remote machine, create a .rhosts file with contents similar to the following (as applicable): root student
  • On the local machine, run the command:
    [root@linuxbox ~]# rcp largefile user@remote.machine:/path/for/saving
  • If you need time statistics for comparison, you can always run the command with the time prefixed:
    [root@linuxbox ~]# time rcp largefile user@remote.machine:/path/for/saving

This procedure requires the .rhosts file to have host names instead of IP addresses. Resolution by DNS or the /etc/hosts file is required. Let us know if you have any problems running this procedure. As a comparison, we have observed 80 MB/s (bytes, not bits) transfer speeds that come close to the hard disk transfer speeds of our simple desktops on a Gigabit LAN.