30

scp works well in all cases, but the Raspberry Pi is to weak to copy files efficiently in a secure environment (lan). The theoretically possible 6,75 MB/s via 54 Mbit wireless lan shrink down to about 1.1 MB/s.

Is there a way to copy files remotely without encryption?

It should be a cli command with no dependencies to extra services (ftp, samba) or at least with a minimum of configuration. I mean, a standard tool that works quite well out-of-the-box with standard programms/services (like scp/ssh).

4
  • 2
    "without any dependencies" is virtually not possible. you will always need a program that "listens" on one side (like the ssh/sftp server when using scp)
    – umläute
    Feb 3, 2014 at 12:00
  • 2
    What about netcat?
    – yegorich
    Feb 3, 2014 at 12:01
  • Okay you're right. I will change the requirements Feb 3, 2014 at 12:01
  • @umläute unless the Client can ssh/rsh to the server and communicate over stdin/out. In the old days piping tar to a remotely invoked tar was the way to easily copy directory trees from one machine to another. Sep 29, 2019 at 10:38

8 Answers 8

17

You might be looking for rcp, it performs remote execution via rsh so you will have to rely on that and have in mind that all communication are insecure.

15

I wrote this quick script:

#!/bin/bash

ssh "$1" "nc -l 2020 > \"$2\" &"
pv "$2" | nc "$1" 2020

It takes two args, the host to send it to and the file you are sending. It only works for one file. It uses ssh to start a netcat listening on the opposite end and then uses netcat to send it to that listening port. I added pv to the start to give a nice progress bar. Replace pv with cat if you don't have or want that. Change the 2020 port to whatever you like. This requires you to have ssh access to the remote system.

This is completely insecure, but then, that's what you wanted.

3
  • Note: some versions of nc may require the receiving command to be written nc -l -p 2020. May 4, 2020 at 3:16
  • I know this comment comes late, but I’d like to point out, for me, nc -l -p 2020 works on macOS, while nc -l 2020 works on Linux.
    – remino
    Aug 16, 2021 at 10:39
  • Recent versions of nc allow the receive buffer size to be specified. For better performance when moving larger amounts of data, using this option makes a big difference. For example, on Linux: nc -l -p 2020 -I 4194304 Jun 9, 2022 at 15:17
14

You cannot disable encryption completely on ssh/scp but you can force it to use a weaker cipher that is much less cpu intensive. Make sure that compression is not turned on in your ssh_config or on the command line and add -c arcfour,blowfish-cbc to your scp command line to select weaker ciphers.

4
  • 2
    This is a nice idea. Is this possible for host specific config? (.ssh/config) Feb 3, 2014 at 17:27
  • 4
    @ManuelSchneid3r: Yes: under a Host section in your ssh_config, use Ciphers arcfour,blowfish-cbc to mirror the above -c switch. However, if your CPUs support the AES-NI instruction set, I'd try switching to [email protected] (yes, that's the cipher name, including the @ stuff), which will use the blazingly fast (with AES-NI) AES128-GCM.
    – Reid
    Feb 3, 2014 at 17:51
  • I wouldn't really call blowfish a weak cipher an in general case (i.e. not R-Pi) AEs might be boosted by hw acceleration.
    – peterph
    Oct 21, 2014 at 21:22
  • As of 2022 arcfour and blowfish are not usable with MacOS -> Ubuntu 21.10. Feb 27, 2022 at 13:15
10

I think NFS is quite underrated for this sort of task, where you want convenience, speed and don't care about security. NFS is really simple to set up, especially on the client: see this short guide for ubuntu, together with this longer ubuntu community help page. From the client's perspective you just mount the server directory and it looks just like a local drive and you can use cp or rsync or whatever commands you want.

2
  • 1
    What are your experiences with what kinds of speed to expect? Jan 6, 2019 at 2:16
  • 1
    @Thorbjørn Ravn Andersen for NFS using gigabit Ethernet and PCIe3 x4 SSDs I found the network was the bottleneck. Using QDR Infiniband instead of gigabit Ethernet the SSDs were the bottleneck. Linux' kernel NFS server is fairly low overhead.
    – Eric M
    Sep 25, 2019 at 17:15
5

The above bash script by Ben Collins is a good solution, but he is missing the -p flag for the port on the server side. Running that as is would just give you an empty file or a hung server that never does anything.

It's easier to see what this is doing if you just look at the commands.

DestinationShell# nc -l -p 2020 > file.txt

SourceShell# cat file.txt | nc dest.ip.address 2020

nc, or netcat, is just like cat except for the output is echoed into another machine through a TCP connection. You're just pushing the output of nc on the server into the destination file. You can setup the Destination in the same way and do echo foo | nc dest.ip.address 2020 and do all sorts of other things with nc.

4

There are patches for openssh for HPC (High Performance Computing) that improve ssh throughput by increasing transfer window sizes and disabling encryption - if you don't mind recompiling (and probably forward-porting patches), check HPN-SSH. As BowlOfRed noticed in the comment, you'd need to use the patches on both the client and the server.

You can also use rsync - on one machine as a daemon and as a simple client on the other one. It is particularly useful for synchronising larger volumes over network link that is slower than reading (and checksumming) the files, since it is able to transfer just those parts of files that differ between client and server. See rsync(1) and rsyncd.conf(5) man pages for details.

2
  • 4
    This was not explicit in your answer, but these patches include the ability to use the "none" cipher in SSH (in other words, disable encryption entirely). The drawback is that you have to apply and run it on both ends. A normal server won't accept the "none" cipher.
    – BowlOfRed
    Oct 21, 2014 at 23:06
  • Very good point!
    – peterph
    Oct 22, 2014 at 8:48
4

it has been some time since the last update, some ciphers have changed, and at least on freeBSD, the blowfish is no longer available. The fastest cipher I found with current ssh installations is -c aes128-cbc.

Enjoy.

1
  • It's deprecated and i could not even enable it. Using rsync -e 'ssh -c [email protected]' ...
    – Ivan
    Apr 29, 2021 at 20:53
4

If you want to transfer entire file structures use tar.

in the receiving system:

[]# nc -l 2020 | tar xvf -

then on the sending system:

[]# tar cvf - | nc dst.hostname.net 2020

Watch the the files archive on one system and extract on the other ;)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .