OpenSSH 9.6p1: What is the best key type for the ssh-keygen command through the -t option?

Hello Friends

Because there is no a security category is posted here.

About the ssh-keygen command to generate the pair of keys files is used the -t option. Now according with the man - noble (1) ssh-keygen.1.gz for the mentioned option it indicates:

-t dsa | ecdsa | ecdsa-sk | ed25519 | ed25519-sk | rsa
             Specifies the type of key to create.  The possible values are “dsa”, “ecdsa”,
             “ecdsa-sk”, “ed25519”, “ed25519-sk”, or “rsa”.

I read a lot of tutorials using -t rsa but I found these posts too:

Both written at yr 2016 and because now we are in yr 2024 I am assuming that something could had been already changed. I mean a new type suggested and not mentioned at all in the 2 links shared above

Therefore having Ubuntu Server 24.04 working with OpenSSH 9.6p1 and assuming that Ubuntu Desktop 24.04 to be used as client uses the same version of OpenSSH to generate the keys files through the ssh-keygen command

Question

  • OpenSSH 9.6p1: What is the best key type for the ssh-keygen command through the -t option?

To be honest would be very nice add in the official OpenSSH page a table indicating for each release what key type should be used. Of course it as a suggestion. So far I only could find the following deprecation note at OpenSSH - Release 8.9 as follows:

ssh(1), ssh(8): since DSA keys are deprecated, move them to the
   end of the default list of public keys so that they will be tried
   last. PR#295

Thanks for your understanding

1 Like

We just went through a bit of this at work when creating a new AMI for future instances on AWS. It seemed like the suggestion was to use ecdsa and not rsa. Something about rsa not being as hard to crack I think. Also, the key produced is a bit smaller. That really shouldn’t be a problem though.

1 Like

I just go with the default - RSA I think… Last 15 years or so?

I used to specify DSA when I worked on Solaris UNIX systems - these days - just use the “default”…

And I don’t have a huge collection of keys anyway…

i.e. when I create a new key I just type ssh-keygen and accept the defaults… works for me…

1 Like

Your question piqued my curiousity. I have been using key pair authentication for some years now. I used this command to generate the key pairs: ssh-keygen -t rsa -b 4096

When I would look at the /var/log/auth.log file I’d see messages about deprecated RSA keys. I didn’t know they were telling me about MY deprecated RSA keys, I thought it was related to unsuccessful login attempts by others.

I found this info at What is ssh-keygen & How to Use It to Generate a New SSH Key?

"Choosing an Algorithm and Key Size

SSH supports several public key algorithms for authentication keys. These include:

  • rsa - an old algorithm based on the difficulty of factoring large numbers. A key size of at least 2048 bits is recommended for RSA; 4096 bits is better. RSA is getting old and significant advances are being made in factoring. Choosing a different algorithm may be advisable. It is quite possible the RSA algorithm will become practically breakable in the foreseeable future. All SSH clients support this algorithm.
  • dsa - an old US government Digital Signature Algorithm. It is based on the difficulty of computing discrete logarithms. A key size of 1024 would normally be used with it. DSA in its original form is no longer recommended.
  • ecdsa - a new Digital Signature Algorithm standarized by the US government, using elliptic curves. This is probably a good algorithm for current applications. Only three key sizes are supported: 256, 384, and 521 (sic!) bits. We would recommend always using it with 521 bits, since the keys are still small and probably more secure than the smaller keys (even though they should be safe as well). Most SSH clients now support this algorithm.
  • ed25519 - this is a new algorithm added in OpenSSH. Support for it in clients is not yet universal. Thus its use in general purpose applications may not yet be advisable.

The algorithm is selected using the -t option and key size using the -b option. The following commands illustrate:

ssh-keygen -t rsa -b 4096
ssh-keygen -t dsa
ssh-keygen -t ecdsa -b 521
ssh-keygen -t ed25519

(End of quoted text)

Just now I ran the command “ssh-keygen -t ed25519”, copied the public portion to the authorized_keys file on my server, disabled the prior RSA key, and was able to log in as before.

Although the article mentions that support for ed25519 is not yet universal I can say that it works with Ubuntu 24.04 LTS at both ends. The ed25519 public key is not very large. I guess the authentication is not based on factoring a large number but on some other mathematical property. More for me to read…

4 Likes

Some further reading revealed that ed25519 is considered equal in security to an RSA key of about 3000 bits. I had been using RSA keys of 4096 bits so they were, in theory, more secure. However, both ed25519 and RSA-4096 keys are currently unbreakable, requiring billions of years of crunching numbers to be solved.

ed25519 keys allow for faster authentication than RSA. I noticed that when I switched to ed25519, but it’s just a fraction of a second. Once authenticated, the connection is changed to a symmetric key cipher and the through-put is identical—it’s only the authentication step that is faster.

3 Likes

Hello Don

Huge thanks for the experiences shared. Very interesting.

Thanks again!