πŸ” encrypt.tools
PUBLIC-KEY Β· SSH

Ed25519 vs RSA for SSH Keys: Which Should You Generate in 2026?

Ed25519 or RSA? Compare SSH key types on security, size, speed and compatibility, see the exact ssh-keygen commands, and learn what post-quantum SSH changes (and doesn't).

By Β·Β·6 min read

Key takeaways

  • Use Ed25519 for new SSH keys: ssh-keygen -t ed25519 -C "you@example.com". It is fast, compact (a 68-character key body vs. 544 for RSA-3072) and avoids the implementation pitfalls of older algorithms.
  • Use RSA (3072 or 4096 bits) only when you must connect to systems that don't support Ed25519 β€” very old servers, some network appliances and HSMs.
  • Avoid DSA (removed from OpenSSH) and RSA keys below 2048 bits. If a server rejects your RSA key, it's usually because of the old SHA-1 ssh-rsa signature scheme, not the key itself.
  • For the strongest protection, use a hardware-backed ed25519-sk key on a FIDO2 security key, or keep keys in an SSH agent backed by a secure enclave.
  • Post-quantum: OpenSSH already defaults to a hybrid ML-KEM + X25519 key exchange, which protects session traffic. Your Ed25519 *authentication* key does not need replacing yet.

Every time you git push or ssh into a server, a key pair proves who you are without sending a password. Generating one takes a single command β€” but ssh-keygen offers several algorithms, and old tutorials still recommend rsa -b 4096. Here's how the options compare today.

The options at a glance

SSH key algorithms compared (measured with OpenSSH 10)
Key typeSecurity levelPublic key lineVerdict
Ed25519~128-bit~80 chars (97 bytes)Recommended default
ed25519-sk (FIDO2)~128-bit + hardware~120 charsBest if you have a security key
RSA 3072~128-bit~560 chars (569 bytes)Compatibility fallback
RSA 4096~140-bit~740 charsFallback; slower, little real gain
ECDSA P-256~128-bit~160 charsOK, but Ed25519 is simpler and safer
DSA80-bitβ€”Removed from OpenSSH; never use

Why Ed25519 is the default choice

Ed25519 is a signature scheme over Curve25519, designed by Daniel J. Bernstein and colleagues in 2011 and standardized in RFC 8032. Its advantages are practical, not just theoretical:

  • Small keys. A 256-bit Ed25519 key gives roughly the same security as a 3,072-bit RSA key. The whole public key line fits on one terminal row, which makes authorized_keys files readable and copy-paste errors rarer.
  • Fast. Generating an Ed25519 key is instant; signing and verifying are much faster than RSA at equivalent strength.
  • Deterministic signatures. ECDSA needs a fresh random number for every signature, and a weak or repeated one leaks the private key β€” this is how the PlayStation 3 signing key was extracted in 2010. Ed25519 derives that value from the message and key, eliminating the whole failure class.
  • Fewer ways to get it wrong. No parameter choices, no padding schemes, and constant-time implementations by design, which resist timing side channels.
  • Strong private-key protection by default. OpenSSH stores Ed25519 private keys in its own format, encrypted with a passphrase via bcrypt-pbkdf, which is much harder to brute-force than the old PEM format.

Generating an Ed25519 key

ssh-keygen -t ed25519 -C "you@example.com"
# Enter file:  ~/.ssh/id_ed25519   (press Enter for the default)
# Passphrase:  use one β€” it encrypts the private key on disk

$ cat ~/.ssh/id_ed25519.pub
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAA...  you@example.com

$ ssh-keygen -lf ~/.ssh/id_ed25519.pub
256 SHA256:mEMMcnEiCw0jpI+ARdwooLTB8zUghjfYk1rRiSFxkTU you@example.com (ED25519)

The -C comment is just a label to help you recognise the key later. Add -a 100 to raise the number of key-derivation rounds that protect the passphrase (the default is 16) β€” this makes an offline attack on a stolen key file slower at the cost of a fraction of a second when you unlock it.

Then copy the public key to a server with ssh-copy-id user@host, or paste the contents of id_ed25519.pub into GitHub, GitLab or your cloud provider's SSH key settings. Never share the file without `.pub` β€” that's your private key.

When you still need RSA

Ed25519 has been in OpenSSH since 2014 (version 6.5), so almost everything supports it. Exceptions you may hit:

  • Servers running very old distributions (RHEL/CentOS 6 era) or unpatched appliances.
  • Some network gear, embedded devices and legacy SFTP services.
  • Environments that mandate FIPS 186-4–era algorithms (newer FIPS 186-5 does approve EdDSA, but adoption lags).
ssh-keygen -t rsa -b 4096 -C "you@example.com"
# OpenSSH's default RSA size is already 3072 bits if you omit -b

Is RSA-4096 "more secure" than Ed25519? On paper it has a slightly higher classical security level (~140 bits vs. ~128), but 128 bits is already far beyond any feasible attack. In practice RSA-4096 just means larger keys and slower handshakes. Against a future quantum computer, both RSA and Ed25519 fall equally β€” size doesn't save RSA.

The "ssh-rsa" confusion

Since OpenSSH 8.8 (2021), connections fail with errors like no matching host key type found. Their offer: ssh-rsa. This makes many people think RSA keys are banned. They aren't. The name ssh-rsa refers to RSA signatures with SHA-1, which OpenSSH disabled because SHA-1 collisions became practical. The same RSA key works fine with the rsa-sha2-256 and rsa-sha2-512 signature schemes.

So if an old server only speaks ssh-rsa, the right fix is to upgrade the server. As a temporary workaround for one host only, you can re-enable it in ~/.ssh/config with HostKeyAlgorithms +ssh-rsa and PubkeyAcceptedAlgorithms +ssh-rsa β€” never globally.

Hardware-backed keys: ed25519-sk

If you own a FIDO2 security key (YubiKey, SoloKey, Google Titan and others), you can generate a key whose private half never leaves the hardware:

ssh-keygen -t ed25519-sk -O resident -C "you@example.com"

Each login then requires a physical touch, so malware on your laptop can't silently use the key. GitHub, GitLab and recent OpenSSH servers (8.2+) support these. Laptops with a secure enclave (Apple Silicon, TPM 2.0) can offer similar protection through SSH agents like Secretive or a TPM-backed agent.

What post-quantum cryptography changes for SSH

SSH uses public-key cryptography in two different places, and quantum computers threaten them differently:

  1. Key exchange β€” negotiating the session key that encrypts your traffic. An attacker could *record* traffic today and decrypt it once a quantum computer exists ("harvest now, decrypt later"). OpenSSH has defended against this since version 9.0 (2022), and since OpenSSH 10.0 (2025) the default key exchange is mlkem768x25519-sha256, a hybrid of the NIST-standard ML-KEM and classic X25519.
  2. Authentication β€” your Ed25519 or RSA key proving identity. A future quantum computer could forge this, but only in real time β€” it can't retroactively impersonate you in a session that already happened. There's no standardized post-quantum SSH signature in OpenSSH yet.

So keep your Ed25519 key, keep OpenSSH up to date, and you already have the part of post-quantum protection that matters most today. You can check your client's preference with ssh -G example.com | grep kexalgorithms. More in our post-quantum cryptography guide.

Good SSH key hygiene

  • Protect private keys with a passphrase and use ssh-agent (or your OS keychain) so you type it once per session.
  • One key per device, not one key copied everywhere β€” so a lost laptop means revoking one key.
  • Audit `authorized_keys` on servers periodically; remove keys you don't recognise. The SSH fingerprint tool shows the SHA256 fingerprint of a public key so you can match it against ssh-keygen -lf output.
  • Verify host fingerprints the first time you connect to a server instead of blindly typing *yes*.
  • Consider SSH certificates for teams: a CA signs short-lived user keys, so there are no long-lived authorized_keys entries to manage.
FREQUENTLY ASKED

Frequently asked questions

Is Ed25519 more secure than RSA 4096?

+

Both are far beyond feasible attack today. RSA-4096 has a slightly higher theoretical classical security level, but Ed25519 is less prone to implementation mistakes, much faster and far smaller. For SSH, Ed25519 is the recommended choice.

Does GitHub support Ed25519 SSH keys?

+

Yes. GitHub, GitLab and Bitbucket all support Ed25519, and GitHub's own documentation recommends it. GitHub also supports hardware-backed ed25519-sk keys.

Why does my RSA key stop working with 'no matching host key type'?

+

Modern OpenSSH disables the ssh-rsa signature algorithm, which uses SHA-1. The RSA key itself is fine with rsa-sha2-256 or rsa-sha2-512. The server or client is outdated; upgrade it, or re-enable ssh-rsa for that single host as a temporary workaround.

Do I need a post-quantum SSH key?

+

Not yet. Modern OpenSSH already uses a hybrid post-quantum key exchange (ML-KEM with X25519) by default, which protects recorded traffic. Post-quantum authentication keys are not yet standardized in OpenSSH, and authentication can't be attacked retroactively.

TOOLS IN THIS GUIDE

Tools used in this guide

KEEP READING