Take the 2-minute tour ×
Information Security Stack Exchange is a question and answer site for Information security professionals. It's 100% free, no registration required.

As someone who knows little about cryptography, I wonder about the choice I make when creating ssh-keys.

ssh-keygen -t type, where type is either of dsa,rsa and ecdsa.

Googling can give some information about differences between the types, but not anything conclusive. So my question is, are there any "easy" answers for developers/system administrators with little cryptography knowledge, when to choose which key type?

I'm hoping for an answer in the style of "Use DSA for X and Y, RSA for Z, and ECDSA for everything else", but I also realise it's quite possible such simple answers are not available.

share|improve this question
4  
Only RSA is an encryption algorithm. Both DSA and ECDSA are used for digital signing - the latter being an Elliptic Curve implementation of DSA (Digital Signature Algorithm). Elliptic curve cryptography is able to provide the same security level as RSA with a smaller key and is a "lighter calculation" workload-wise. So, use RSA for encryption, DSA for signing and ECDSA for signing on mobile devices. –  Henning Klevjer Oct 30 '12 at 13:01

3 Answers 3

up vote 33 down vote accepted

As per the SSH standard (RFC 4251 and subsequent), a DSA key will work everywhere. In practice, a RSA key will also work everywhere. ECDSA support is newer, so some old client or server may have trouble with ECDSA keys.

ECDSA is computationally lighter, but you'll need a really small client or server (say 50 MHz embedded ARM processor) to notice the difference.

Right now, there is no security-related reason to prefer one type over any other, assuming large enough keys (2048 bits for RSA or DSA, 256 bits for ECDSA); key size is specified with the -b parameter. However, some ssh-keygen versions may reject DSA keys of size other than 1024 bits, which is currently unbroken, but arguably not as robust as could be wished for. So, if you indulge in some slight paranoia, you might prefer RSA.

To sum up, do ssh-keygen -t rsa -b 2048 and you will be happy.

share|improve this answer
6  
DSA always makes me uneasy because a signature generated with a broken RNG can compromise the key. RSA keys have an easier to understand and less worrisome failure mode: generating a key with a broken RNG compromises the key, running a session with a broken RNG compromises the session at most. –  Gilles Oct 30 '12 at 13:26
    
@Thomas I'm curious, since this question was posted before the Snowden affair. Has anything recently come to light that would affect this answer? –  user50849 Sep 5 at 8:37
    
No. In fact, everything that was revealed in that affair only confirms what was already known, i.e. that when big governmental agencies spy on people, then don't do it by trying to break cryptography upfront; they rather work around it. In the SSH case, they would collect metadata (this client machine connects to that server) that is not protected by the SSH protocol, regardless of the server key algorithm or size. –  Thomas Pornin Sep 5 at 11:28

DSA and ECDSA have fixed length keys, and they are US government standards meaning that they know more about the standards than the general public. RSA is better known and you can generate longer keys with it (default is 2048 as opposed to DSA's 1024 bit fixed length), so it is (arguably) better to use.

share|improve this answer
    
According to the ssh-keygen man page, you have three choices for ECDSA key lengths: For ECDSA keys, the -b flag determines the key length by selecting from one of three elliptic curve sizes: 256, 384 or 521 bits. Attempting to use bit lengths other than these three values for ECDSA keys will fail. –  jfmercer Nov 23 '13 at 2:31
    
@jfmercer 521 or 512? –  Anonymouse Aug 6 at 18:01
1  
@Anonymouse it's really 521. See also crypto.stackexchange.com/questions/2482/… –  nodakai Aug 21 at 10:10
    
@Anonymouse See Why do the elliptic curves recommended by NIST use 521 bits rather than 512?. In short, P521 uses this prime because 2^521-1 is a mersenne prime. –  CodesInChaos Oct 21 at 11:51

As gilles says DSA is risky because if you make signatures (and using your key with a ssh client to log in is effectively making signatures) on a box with a bad RNG your key can be compromised. AIUI this made debian basically abandon DSA for keys used on their infrastructure in light of the debian openssl random number generator fiasco.

http://meyering.net/nuke-your-DSA-keys/

ECDSA is rather new, from some quick searching it seems it was introduced in 5.7 and there are still some supported linux distros that carry older versions of openssh that that. For example debian squeeze and ubuntu lucid. Afaict it has advantages in that a key can be much smaller for the same level of security but a large RSA key is plenty secure enough and not too big to handle.

So IMO that makes RSA (with a 2048 or 4096 bit key depending on how paranoid you are) the most reasonable choice for general use.

share|improve this answer
3  
ECDSA has the same weakness as DSA in this respect. And in OpenSSH it's doubly fishy because OpenSSH only implements NIST curves that are suspected to be backdoored by the NSA. More info here: security.stackexchange.com/a/46781/15087 –  Shnatsel Dec 27 '13 at 21:35

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.