Multi-Threaded SSH/SCP
neo writes "Chris Rapier has presented a paper describing how to dramatically increase the speed of SCP networks. It appears that because SCP relies on a single thread in SSH, the crypto can sometimes be the bottleneck instead of the wire speed. Their new implementation (HPN-SSH) takes advantage of multi-threaded capable systems dramatically increasing the speed of securely copying files. They are currently looking for potential users with very high bandwidth to test the upper limits of the system."
Hi, I've invented a new way of downloading pron^H^H^H^H^H^Hcopying files across a network. If you have uber bandwidth, please contact me urgently!
I wrote my first program at the age of six, and I still can't work out how this website works.
not that scp as-is isn'--stalled--
I get a lot of use out of ssh for moving files around and rsync is definitely the best way to do heavy lifting in this area. Improving scp would be good to. I can't wait to hear what Theo thinks about this. I don't see him as a fan of adding complexity to improve performance.
Big scp copies through my wifi router used to cause kernel panics under netbsd current of about a year ago. I never had that problem running rsync inside ssh.
http://michaelsmith.id.au
If you want to speed up transfers and you're working on a LAN you trust (i.e. you don't worry about the integrity and confidentiality of the data passing through it), you can dramatically increase throughput using socketpipe. Although the initial socketpipe communication setup is performed through client-server intermediaries such as ssh(1), the communication channel that socketpipe establishes is a direct socket connection between the local and the remote commands. This eliminates not only the encryption/description overhead, but also the copying between your processes and ssh or rsh.
How will this affect the operation of applications wich use SSH to standardie applications accross Linux like urpmi's --parallel parameter?
This is one of the most useful aspects of Mandriva, but as the number of nodes I have to manage increases, I find RPMS being SCPed to other nodes taking longer and longer. I think this is because even though with Kerberos Authentication is much faster, urpmi is waiting until one node finishes copying the files to start copying to the next node in the Domain.
Thoughts?
I really hope this will make it into OpenSSH after some security auditing. The performance gains was pretty impressive. It will make ssh much more fun for rsync, backups and other times when i transfer large files. I also wonder if one cant get similar performance gains with normal ssh and for example forwarded X-windows. That would be very interesting indeed.
HTTP/1.1 400
You can also use a cheaper cipher. From the ssh manpage:
-c blowfish|3des|des
Selects the cipher to use for encrypting the session. 3des is
used by default. It is believed to be secure. 3des (triple-des)
is an encrypt-decrypt-encrypt triple with three different keys.
blowfish is a fast block cipher, it appears very secure and is
much faster than 3des. des is only supported in the ssh client
for interoperability with legacy protocol 1 implementations that
do not support the 3des cipher. Its use is strongly discouraged
due to cryptographic weaknesses.
I'm sorry if I haven't offended anyone
the crypto can sometimes be the bottleneck instead of the wire speed.
Between two devices on my gigabit home LAN, the CPU barely even registers while SCP'ing a large file (and that with every CPU-expensive protocol option turned on, including compression). What sort of connection do these guys have, that the CPU overhead of en/decryption throttles the transfer???
Coming next week: SSH compromised via a thread injection attack, thanks to a "feature" that only benefits those of us running our own undersea fiber.
Aw man, if only I had this yesterday! Just had someone download ~6GB worth of video files from one of my machines and just as it shows in the article, throughput was pegged at ~2MB/sec. It took most of a day to send it. This would also kick some serious bootae for uploads to YouTube if they were to ever implement it... for those of us uploading GBs of GBs of stuff.
Wally: "My proposed work plan for the year is to stress-test our product under severe network conditions. I will accomplish this by downloading large image files from the busiest servers on the net."
(PHB rejects suggestion)
(later)
Wally: "I was this close to making it my job to download naughty pictures."
Dilbert : "It's just as well; I would have had to kill you."
( http://books.google.com/books?id=dCeVfKrZ-3MC&pg=PA77&source=gbs_selected_pages&cad=0_1&sig=xD5tmMhG1RcspLch8gCIJu8ro2U#PPA79,M1 )
Oh, I can't help quoting you because everything that you said rings true
Or just compile from source and enable the 'none' "cipher".
I surely missed having that option when copying files between hosts on my LAN. I don't need to hide data from myself. If someone else connects and encrypting data is a concern, I'll simply not use the 'none' "cipher".
Or use netcat/nc (installed by default on most Linux distros). Server cats it's output directly to a file (or to tar -x). Client grabs it's input from a file.
Server: nc -l 1234 | tar -x
Client: tar -c file_list_here | nc localhost 1234
And if you really trust your network, you can recompile SSH with the 'none' cipher enabled, which (as the name implied) uses no encryption on the datastream whatsoever.
Preferably, we would like to test it any very high bandwidth systems running Linux kernels version 2.6.17 to 2.6.24.1.
There exists already a multi-threaded & multi-stream file transfer tool, bbftp. It is not a drop-in replacement for scp, as it uses a protocol optimized for bulk files, but doubtless some of its ideas could be backported.
By the way, does anybody else think "the ability to switch to a NONE cipher post authentication" is pretty dodgy?
Watch this Heartland Institute video
I've been wondering, does there exist hardware accelerators usable by OpenSSL or GnuTLS? I work in embedded systems, and our chip includes a crypto and hash processor. I'm surprised nothing equivalent exists on modern PCs, or have I just not been looking in the right places?
Misleading titles? Inflammatory blurbs? Keep in mind that Slashdot is a tabloid.
Actually, it appears that (at least on Debian) AES is already the default. Selecting 3des gives tremendous slowdown; blowfish is somewhat slower than AES.
Copying 100MB of data over 100mbit ethernet to a P2 350Mhz box (the slowest I got) gives:
* 3des 1.9MB/s
* AES 4.8MB/s
* blowfish 4.4MB/s
The creatures outside looked from Alt-Right to Antifa; but already it was impossible to say which was which.
sftp still not have an ASCII transfer mode, unlike the ftp it replaces. What is the deal with this? How much extra code would it take to do this? Of course you can workaround it, but it wastes times and causes confusion and complaints (google sftp and ascii).
This is the setup using nc:
and this is the setup that socketpipe arranges:
Crowds were shocked to discover that multi-threaded software runs faster on a multi-core system, it was hard to contain the excitement over the discovery which could revolutionise software development!
I don't get it, if they need lots of bandwidth to test their scp acceleration code, why can't they do it over the loopback interface?
Is there some limit to that I'm not aware of?
Truth arises more readily from error than from confusion. -Francis Bacon
it's weird that they look for high bandwidth users only. they could also use low-powered systems to test the approach :)
of course, if they want to test how well it scales, that's a different matter.
Rich
"They are currently looking for potential users with very high bandwidth to test the upper limits of the system."
You comcast users can forget about it, then.
More music, fewer hits
The situation where this can be usefull will be almost non-existing. The places that could benefit from the increase will most likely have several people working.
That means the better way is to encrypt BY DEFAULT. Security is not so much a technical issue. It is also a social one. Encrypting by default will benefit you in the long run.
This means also sending gpg signed messages by default. Much shorter, beter and more usefull then the legal sh|t they attach now.
Don't fight for your country, if your country does not fight for you.
Digging around for the best way to apply the patch without screwing up my portage updates, I came across a request for this to be merged into the portage back in 2005, and is apparently usable with the HPN useflag.
Not that I'm that surprised to see this is old news, since they're apparently on major revision 13...
I surely missed having that option when copying files between hosts on my LAN. I don't need to hide data from myself. If someone else connects and encrypting data is a concern, I'll simply not use the 'none' "cipher". -1 redundant, -1 fail at slashdot
from the linked article: Dynamic Windows and None Cipher
This is a basis of the HPN-SSH patch set. It provides dynamic window in SSH and the ability to switch to a NONE cipher post authentication. Based on the HPN12 v20 patch.
It can also be done in another way, using standard ssh (so it can be used on a lan you don't trust):
/path/to/remotedir
tar zcf - * | ssh remotehost tar zxvf - -C
You also get compression on the fly, which helps a bit; replace ssh with rsh if you wish.
It also works out of the box across different *nix variants: no problem if you don't have socketpipe on the receiving end (i'm assuming it's less widely available tha ssh).
Regards,
Alberto.
Actually, it depends upon the SSH protocol. Both Debian and Cygwin have this to say:
-c cipher_spec
Selects the cipher specification for encrypting the session.
Protocol version 1 allows specification of a single cipher. The
supported values are "3des", "blowfish", and
"des". 3des (triple-des) is an encrypt-decrypt-encrypt
triple with three different keys. It is believed to be secure.
blowfish is a fast block cipher; it appears very secure and is
much faster than 3des. des is only supported in the ssh client
for interoperability with legacy protocol 1 implementations that
do not support the 3des cipher. Its use is strongly
discouraged due to cryptographic weaknesses. The default
is "3des".
For protocol version 2, cipher_spec is a comma-separated list of
ciphers listed in order of preference. The supported ciphers are:
3des-cbc, aes128-cbc, aes192-cbc, aes256-cbc, aes128-ctr,
aes192-ctr, aes256-ctr, arc
four128, arcfour256, arcfour, blowfish-cbc, and cast128-cbc. The default is:
aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour128,
arcfour256,arcfour,aes192-cbc,aes256-cbc,aes128-ctr,
aes192-ctr,aes256-ctr
UNIX/Linux Consulting
Today you can buy a machine with eight cores, 8gb memory and 1tb harddrive for less than 2000. And most software will only use one core and a maximum of 2gb memory.
WE NEED MULTITHREADING NOW BIG AND EVERYWHERE.
Multithreading is maybe the biggest change in software development. In contrast to advanced command sets like MMX, SSE and so on it is not about some peep hole optimization, about replacing a bunch of x86_32 commands with some SSE commands, it is about changing the whole approach, finding new algorithms and redevelop much if not all software we are used to work with.
And we are lightyears away from using appropiate software on on todays systems.
See compressors: Most can't multithread at all. Those who can have more issues than the SCO buisness plan, eg reduced efficency, scale very bad, can't accept input from stdio or can't output on stdout. Basically compression should be a good starting point but even here todays solutions are incredible far behind the hardware.
Also consider network communication, graphical interfaces, games, printing, non-enterprise realtime presentation and so on and so forth.
The revolution is NOT here. People aren't even talking about it.
"Life is short and in most cases it ends with death." Sir Sinclair
Srsly. I'm gonna be a father this year. DO NOT WANT!
I may be speaking out of ignorance, but doesn't that defeat the point of SSH?
"Our opponent is an alien starship packed with atomic bombs. We have a protractor."
There is also no security in socketpipes, so it isn't much different from using FTP from a security standpoint.
I think the point of this article is to improve a "secure" method of data transfer by making the way it deals with encryption better. Even using weaker encryption methods, you still have this problem.
I think the idea makes perfect sense and probably could improve file transfer dramatically. Realistically, it is just a software encryption accelerator. If they could implement it in the NIC card, that would be a better solution, but probably a headache from a OS programming/encryption update standpoint.
Okay, it's very simple.
/some/path myhost.com:my/directory
/some/path rsync://myhost.com/my/directory OR /some/path myhost.com::my/directory
Encrypted and tunneled over SSH, rsync is spawned by a login shell at the other side:
rsync
Not encrypted, rsyncs daemon must be running at other end:
rsync
rsync
A cat can't teach a dog to bark.
The "point" is whatever you want it to be. When copying files on my LAN, I still want secure password exchange, but I could give a shit about the data. I don't know if it's actually possible to achieve this (encrypt only for exchange) with ssh or not, though.
"You're right," Fisheye says. "I should have set it on 'whip' or 'chop.'"
High Performance Bulk Data Transfers Using the SSH Protocol
If you just recompile the stock SSH with the NONE cipher enabled the entire process happens in clear. This includes the authentication. You can test this by capturing the network activity with TCP dump (use a full snaplen) and looking at the results. You'll find that your key/password/whatever is in plaintext. The NONE cipher switch available in HPN-SSH is different in that the authentication *is* encrypted and the NONE cipher is only used *after* the user is authenticated.
AFAIK, the OpenBSD kernel has adopted the SMP approach of the Linux 2.2 kernel (i.e. one great big kernel lock), and threads are implemented in a userland library. I assume that there will be less of a performance benefit on OpenBSD.
Given this stance, is it very likely that either the core maintainers, or the maintainers for the portable releases, will integrate this code?
Given the danger of protecting critical sections of code from race conditions and other exploits, should we keep things simple?
p.s. Is there any performance loss when using the privilege separation multi-process model? Could this threading approach from the article be reworked to use standard SysV IPC to make better use of these processes?
I don't know about you but I've been using the HPN variant of OpenSSH from MacPorts for a couple of years now. Don't know why this is news.
Multithreading is maybe the biggest change in software development. In contrast to advanced command sets like MMX, SSE and so on it is not about some peep hole optimization, about replacing a bunch of x86_32 commands with some SSE commands, it is about changing the whole approach, finding new algorithms and redevelop much if not all software we are used to work with.
This is a good point, although multithreading is not a new thing. It does often take a complete rework of existing algorithms in order to leverage the benefits of parallelism, though. Just keep in mind that there's no free lunch. Just because you throw, for example, twice the processor resources at a problem, does not mean you'll get twice the speedup. You can approach that (but almost never reach it), as contention for shared resources, dependence on results produced by other code, etc. reduces these improvements somewhat. It all depends on how much of the code needs to run serially, and how much is independent of other things and can run in parallel. In the case of SSH, we're talking about using multithreading for buffering completely independent data sets, so the improvement is good. In general though, you still do reap the benefits of being able to share code pages which may offer speed and memory footprint advantages over simple copy-on-write, multi-process programming.
"Ein Volk, ein Reich, ein Führer." -Adolf Hitler
"We are one Nation, we are one People." -The One 'leader'
rsync.net would be happy to offer bandwidth and support to the authors - please contact info@rsync.net if these resources are still needed for your project. Much of what we do is based on SCP, so we were happy to see this announcement.
SSH is one of those uberutilities that has a surprising amount of usefulness once you dig a bit. Sure, secure telnet functionality is great, and I use it a lot. But, I still use ssh on my own LAN where I don't really care about security. I use sshfs because it is easier and more convenient for me than bothering with Samba. SCP/SFTP to avoid bothering with ftp. I use it for forwarding ports between various machines, and I use it for forwarding X sessions. There are surely ways to accomplish all the same stuff that I use ssh (and the closely related stuff like scp) for without using ssh, but I'd just rather not bother about it.
Defeating the point of ssh is like defeating the point of a morning star. No matter how dull you make the point, the other 99 of them will still clobber you in the face.
That's protocol v. 1. Protocol version 2, which we should all be using, will try aes128-cbc first off, and that should be one of the fastest ciphers available. /etc/ssh/sshd_config | grep Pro
$ cat
Protocol 2
"It doesn't cost enough, and it makes too much sense."
SCP is OK for one or two files, but isn't there something better for moving large files in a secure way.
This is coming from a person who gets made at people for using FTP (or worse email) on there student accounts for file transfer when its possible to use SMB ( and I think even NFS) and mount them directly.
A couple notes about the multi-threading: The main goal was to allow SSH to make use of multiple processing cores. The stock OpenSSH is, by design, limited to using one core. As such a user can encounter situations where they have more network capacity and more compute capacity but will be unable to exploit them. The goal of this patch was to allow users to make full use of the resources available too them. The upshot of this is that its best suited for high performance network and compute environments (The HPN in HPN-SSH stands for High Performance Networking). This doesn't mean it won't be useful to home users - only that they might not see the dramatic performance gains someone in a higher capacity environment might see. Its really going to depend on the specifics of their environment.
Based on our research we decided the most effective way to do this would be to make the AES-CTR mode cipher multi-threaded. The CTR mode is well suited to threading because there is no inter block dependency and, even better, the resulting cypher stream is indistinguishable from a single threaded CTR mode cypher stream. As a result, we retain full compatibility with other implementations of SSH - you don't need to have HPN-SSH on both sides of the connection. Of course, you won't see the same improvements unless you do.
We still see this as somewhat experimental because we've not yet implemented a way to allow users to choose between a single threaded AES-CTR and multi-threaded AES-CTR mode. As such users on single core machines - if using AES-CTR may see a decrease in performance. We suggest those users just make use of the AES-CBC mode instead (which is the default anyway). Also, you need to be able to support posix threads.
Future work will involve pipelining the MAC routine and that should provide us with another 30% or so improvement in throughput.
Also, its important to keep in mind that these improvements are *not* just for SCP but for SSH as a whole. People using HPN-SSH as a transport mechanism for rsync, tunnels, pipes, and so forth may also see considerable performance improvements. Additionally, the windowing patches don't necessarily require HPN-SSH to be installed on both ends of the connection. As long as the patch is installed on the receiving side (the data sink) you may (assuming you were previously window limited) see a performance gain.
We welcome any comments, suggests, ideas, or problem reports you might have regarding the HPN-SSH patch. Go the website mentioned above and use the email address there to get in touch with us. This is a work in progress and we are doing what we can to enable line rate easy to use fully encrypted communications. We've a lot more to do but I hope what we've done so far is of use and value to the community.
Comment removed based on user account deletion
I found out about this and the PSC patch about 8 months ago when I setup a 20GB Infiniband network in our data center.
This technique would be great for virtual machine instances hosted in simulation environments (eg. bochs).
In other words, by default you'll get aes, unless you happen to connect to a server that doesn't support it (unlikely). So the question is, which of these is fastest?
In Soviet Russia, SSH Multi-Threads You.
Sorry, I don't have mod points today to do it myself. Recommend +1 Interesting or +1 Insightful.
Hey, Windows users, there is no such thing as "forward" slash, there is only slash and backslash.
I've heard more and more people saying this lately. Why not use NFS? It saves the crypto overhead, is massively easy to set up on both the client and server side, etc etc. Agree about Samba though - using it for *nix-to-*nix shares is idiotic.
Causation can cause correlation
The downside to NFS is of course that you pretty much need network-wide logins (via Kerberos or some other method) to keep your UID the same on all machines, you can always do it the ugly way and simply set the UIDs on the NFS partition to whatever UID you have on the machine you normally access it from but once you have a few different machines and users it just becomes easier to set up Kerberos...
/Mikael (uses NFS because it doesn't act up nearly as often as Samba)
Greylisting is to SMTP as NAT is to IPv4
I believe heavy use of SSE3/SSE4 instructions can provide much better performance than going multi-threaded. Multi-threaded is only easier.
I have a simple fileserver and transfer system I wrote in java to facilitate transferring files and information between hosts in our application. It also allowed me to take specific acts on certain types of files (like expanding zip files or installing jar files for our application).
Writing it multithreaded seemed obvious. But when I look at all the insane patents that are being granted, as crazy as it sounds, someone could actually patent a "file server/transfer system using multiple threads to enable simultaneous transfers and non-file information as well as intelligent handling of specific file types."
Any normal person would say, "Hey ftp does most of that already" but the way the patent office works today you could still get a patent on it.
... AST: Multi-threaded SSH/SCP "is only a performance hack". :)
.sig: No such file or directory
Please, in the name of all that is holy (relative to $deity of your choice), make that version detect and handle softlinks correctly!
... to anything designed to secure ALWAYS makes it more secure, historically.
I think I'll wait for version 2, or 3... maybe 10.
+++OK ATH