You can use pigz with SSH as you can pipe commands over SSH (google it). If nc is faster than scp, I guess encryption is a factor, but then they're not comparable solutions to the same problem.
Sure you can :). Naturally transfers via SSH "suffer" from the encryption overhead but prevent MITM/network sniffing etc. The author points out that (only) in a trusted LAN you could use this solution to make things go faster.
I guess the title should be a little more mild - scp isn't going away, or rsync via SSH for that matter.
Speaking generally, rsync is faster than straight copying if the files partially exist in the destination first. If they don't exist, or they've changed completely, rsync is slower due to the checksumming on both sides.
Finally, there is one advantage that scp still holds: its transfer is secure while pigz/nc transfers data in clear text. So, if you are using unsecured networks, this option is probably not for you."
Yeah, but it will need executing commands on both hosts. SSH works on top of SCP and only needs running sshd on the remote host and access to that machine.
All those solutions ( from the OP ) are faster, but you will need some setup, before you could use it from one host remotely and in the end you might end up using good old SMB or NFS which will give you speed ( http://www.linuxquestions.org/questions/linux-networking-3/s... )
You can pipe through GPG with the -c (--symmetric) flag. Using a reasonably efficient cipher (AES256) has negligible impact on speed and minor CPU usage. I do this with automated DB backups.
xz supports multiple threads, if CPU is no object. If you want to stream the results why not use ssh's -F option to create a secure tunnel, particularly if the required bandwidth is not high.
Which version of xz started supporting multiple threads?
My version latest from Debian testing (yes I know it is not cuting edge) says in man page:
Multithreaded compression and decompression are not implemented yet, so this option has no effect for now.
One good alternative I've used is socketpipe[0]. It handles logging into the remote server, setting up a listener, and then piping the data over.
But, that tunnel still isn't encrypted. So, either encrypt your data first, or setup some vpn tunnel. The inefficiency of scp isn't just due to the encryption, there's overhead in the ssh protocol.
A VPN setup seems like overkill. You can run stunnel and run a daemon to loop back through the stunnel configured connection. It's not quite as easy to use offhand like scp, but it's certainly not as awkward to try to use as a random series of OpenSSL commands either and it'll be easier to understand what you tried to do later on the production machine.
Surprised to see NC slower than SSH on network throughput. All of the authors benefits came from compressing the payload first.. Curious if enabling compression at the highest levels for SSH would have worked, or as others suggested, piping pigs over the SSH connection itself.
I used pigz for compressing and then rsync for transferring my (Postgre)SQL logs. The reason being that pigz has a built-in "rsyncable" mode, which allows rsync to avoid sending the whole log over always. The multicore compressing is just icing on the cake. gzip has a patch for an "rsyncable" mode, but it's no longer properly included in the distro's I use (debian).
At some point, the only way to copy data faster is to not copy it at all.
xz + scp will still be faster than this.
its not about the speed at which scp goes, is that the author doesn't compression before sending over scp, but does when he sends over nc and what not...
heck you can just use rsync over SSH for simplicity.
That's not the case if the data you're sending is already compressed. But you're right that it's not a fair comparison. scp/ssh also has integrated compression with "-C".
scp's beauty is in its ubiquity. That host over there that I want to copy to? I need no extra configuration there because sshd is already running.
I agree that scp is dog slow and it can be pretty frustrating. As others have mentioned, cranking down the cipher provides a modest improvement. Ad-hoc netcat based solutions like this one are the way to go if you need throughput and not security.
34 comments
[ 3.1 ms ] story [ 40.2 ms ] threadHave you also done any testing with ssh + gzip?
Also, as you note at the end, the security concerns are not trivial.
I guess the title should be a little more mild - scp isn't going away, or rsync via SSH for that matter.
If the answer is yes, then why they are compared here? Anyone on public network might sniff what you are actually sending / receiving.
"tar/pigz/nc transfer is not secure
Finally, there is one advantage that scp still holds: its transfer is secure while pigz/nc transfers data in clear text. So, if you are using unsecured networks, this option is probably not for you."
tar -cf - /u02/databases/mydb/data_file-1.dbf | pigz | ssh user@destination "pigz -d | tar xf - -C /"
All those solutions ( from the OP ) are faster, but you will need some setup, before you could use it from one host remotely and in the end you might end up using good old SMB or NFS which will give you speed ( http://www.linuxquestions.org/questions/linux-networking-3/s... )
My version latest from Debian testing (yes I know it is not cuting edge) says in man page: Multithreaded compression and decompression are not implemented yet, so this option has no effect for now.
But, that tunnel still isn't encrypted. So, either encrypt your data first, or setup some vpn tunnel. The inefficiency of scp isn't just due to the encryption, there's overhead in the ssh protocol.
0 http://freecode.com/projects/socketpipe
At some point, the only way to copy data faster is to not copy it at all.
I wrote a blog post about it here: http://www.aktau.be/2014/10/23/pg-dump-and-pigz-easy-rsyncab...
http://www.psc.edu/index.php/hpn-ssh
It's able to consistently fill 1G ethernet links.
bbcp,[2] which was mentioned in the original article, also looks promising. Particularly because it actually uses ssh, unlike pigz and nc.
[1] - https://news.ycombinator.com/item?id=4710061
[2] - http://www.slac.stanford.edu/~abh/bbcp/
The main difference now it that hpn tweaks the tcp window to function better on high-latency links.
> It's able to consistently fill 1G ethernet links.
Between two stock Debian sid laptops:
That's 90% of the theoretical bandwith, right?If you're really transferring huge file files across fat WAN links, why not use GridFTP like the supercomputing centers use? They transfer TB daily.
I wouldn't mess with patching openssh, especially with patches for old versions of openssh.
heck you can just use rsync over SSH for simplicity.
That's not the case if the data you're sending is already compressed. But you're right that it's not a fair comparison. scp/ssh also has integrated compression with "-C".
xz: tar -cJ /home/me/source/directory | ssh target tar -xJ --directory /home/you/target/directory
ssh -C won't be as good. in particular with a recent xz that's threaded it will probably be faster than OP's with a good CPU
If you still have the setup up and running, throw this in the mix:
and still encrypted! The latter enables compression, but I've found it slower when dealing with several small files (ex: source code files)I agree that scp is dog slow and it can be pretty frustrating. As others have mentioned, cranking down the cipher provides a modest improvement. Ad-hoc netcat based solutions like this one are the way to go if you need throughput and not security.