Using ECDSA to Replace RSA for SSH Key Generation
RSA
Many people still use the RSA algorithm to generate SSH public keys. You might even wonder how many bits are safe enough. The general recommendation is 4096 bits:
1 | ssh-keygen -t rsa -b 4096 -C "your_email@example.com" |
This results in a very long public key:
1 | cat test_rsa_4096.pub |
Ed25519
There are actually more advanced algorithms that are more secure than RSA, with shorter public keys. Thanks to blockchain adoption, they’re gaining more acceptance. For example, Ed25519, despite being only 256 bits, offers higher security than RSA 3072.
Generating an Ed25519 SSH Key:
1 | ssh-keygen -t ed25519 -C "your_email@example.com" |
Public key:
1 | cat test_ed25519.pub |
GitHub now recommends Ed25519 by default: https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent
Ed25519 is an elliptic curve — elegant and with mathematically proven security:
By Deirdre Connolly in [State of the Curve] (2016)
Here’s a list of current Ed25519 adopters: https://ianix.com/pub/ed25519-deployment.html