17

In my /etc/ssh/ directory, I can see three that I have three different types of ssh keys:

-rw------- 1 root root    607 Oct  4 22:43 ssh_host_dsa_key
-rw-r--r-- 1 root root    623 Oct  4 22:43 ssh_host_dsa_key.pub
-rw------- 1 root root    241 Oct  4 22:43 ssh_host_ecdsa_key
-rw-r--r-- 1 root root    194 Oct  4 22:43 ssh_host_ecdsa_key.pub
-rw------- 1 root root   1602 Oct  4 22:43 ssh_host_rsa_key
-rw-r--r-- 1 root root    378 Oct  4 22:43 ssh_host_rsa_key.pub

What is are the differences between ssh's RSA, DSA, and ECDSA keys, and do I need all three?

2 Answers 2

14

Do you need all of them?
No, your ssh server only needs one and the client only needs to support that one type of key for ssh connections.


RSA, DSA, ECDSA, EdDSA, & Ed25519 are all used for digital signing, but only RSA can also be used for encrypting.

RSA (Rivest–Shamir–Adleman)is one of the first public-key cryptosystems and is widely used for secure data transmission. It's security relies on integer factorization, so a secure RNG (Random Number Generator) is never needed. Compared to DSA, RSA is faster for signature validation but slower for generation.

DSA (Digital Signature Algorithm) is a Federal Information Processing Standard for digital signatures. It's security relies on a discrete logarithmic problem. Compared to RSA, DSA is faster for signature generation but slower for validation. Security can be broken if bad number generators are used.

ECDSA (Elliptical curve Digital Signature Algorithm) is an Elliptic Curve implementation of DSA (Digital Signature Algorithm). Elliptic curve cryptography is able to provide the relatively the same level of security level as RSA with a smaller key. It also shares the disadvantage of DSA of being sensitive to bad RNGs.

EdDSA (Edwards-curve Digital Signature Algorithm) is a digital signature scheme using a variant of Schnorr signature based on Twisted Edwards curves. Signature creation is deterministic in EdDSA and its security is based on the intractability of certain discrete logarithm problems, so it's safer than DSA & ECDSA which requires high quality randomness for each and every signature.

Ed25519, is the EdDSA signature scheme, but using SHA-512/256 and Curve25519; it's a secure elliptical curve that offers better security than DSA, ECDSA, & EdDSA, plus has better performance (not humanly noticeable).


Other notes
RSA keys are the most widely used, and so seem to be the best supported.

ECDSA, (introduced in OpenSSH v5.7), is computationally lighter than DSA, but the difference isn't noticeable unless you have a machine with very low processing power.

As of OpenSSH 7.0, SSH no longer supports DSA keys (ssh-dss) by default. A DSA key used to work everywhere, as per the SSH standard (RFC 4251 and subsequent).

Ed25519 was introduced in openSSH 6.5.

5
10

They're keys generated using different encryption algorithms. You can choose to use different forms of encryption when using SSH, somewhat similar to the ability to choose different encryption methods for WiFi (WPA2, WPA, WEP, etc).

SSH uses public-key encryption, meaning when you connect to an SSH server it broadcasts a public key which you can use to encrypt further traffic to be sent to that server. If the server is configured to use RSA it will be a key generated by the RSA algorithm.

Your computer sends back its own public RSA key from the key file you listed in your question. The server needs this key to connect back to you and reply.

All three keys exist on your computer because any given SSH server you're connecting to might be configured to use any one of these algorithms. Your computer will send back a unique key matching the type the server uses, your key having been generated on your computer by the same algorithm.

Here's some further resources:

https://security.stackexchange.com/questions/5096/rsa-vs-dsa-for-ssh-authentication-keys

http://en.wikipedia.org/wiki/Public-key_cryptography

http://en.wikipedia.org/wiki/RSA_(algorithm)

http://en.wikipedia.org/wiki/Digital_Signature_Algorithm

http://en.wikipedia.org/wiki/Elliptic_Curve_DSA

1
  • 2
    You briefly talked about why all three are there, the purpose of a ssh key, and what the keys have in common: the keys use encryption algorithms. What you didn't talk about what is the difference between the RSA, DSA, and ECDSA keys. Jan 28, 2018 at 1:20

You must log in to answer this question.

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