Secure Shell (SSH) is the backbone of secure remote access—but with so many key algorithms to choose from, which one should you use? Let’s walk through the history, the trade‑offs, and the modern sweet spot for most users.


Why SSH Keys Matter Today

You’ve probably typed ssh user@server dozens of times—but do you know what’s happening under the hood? SSH key algorithms aren’t just academic: they determine how fast your connections are, how resilient they are to future attacks (think quantum!), and even whether your CI pipeline can talk to GitHub without a hitch.

In this guide you’ll learn:


SSH Asymmetric Encryption in a Nutshell

Pro tip: Always use SSH‑2 (the only supported protocol since 1998) and disable weak ciphers in your sshd_config.


Handy OpenSSH Flags

ssh-keygen -o -a 100 -b <bits> -t <type> -C "[email protected]"

RSA: The Classic Workhorse

Overview: “Rivest–Shamir–Adleman” relies on factoring large n = p · q. Still everywhere thanks to legacy systems.

When to use it:

Generate a 4096‑bit key:

ssh-keygen -t rsa -b 4096 -o -a 100 -C "[email protected]"

How it works:

  1. Pick two large primes p and q.
  2. Compute n = p · q and phi(n) = (p - 1) · (q - 1).
  3. Choose e, compute d as e · d ≡ 1 (mod phi(n)).
  4. Encrypt with c = m^e mod n; decrypt with m = c^d mod n.

Security:


DSA: The Legacy Signature

Overview: Digital Signature Algorithm (ssh-dss) is an older NIST standard locked to 1024 bits and SHA‑1—disabled by default in OpenSSH ≥ 7.0.

When to use it:

Why it’s weak:


ECDSA: Curve‑Based Alternative

Overview: ECDSA uses NIST curves (P‑256/384/521) to offer RSA‑like security with smaller keys.

When to use it:

Generate P‑256 key:

ssh-keygen -t ecdsa -b 256 -o -a 100 -C "[email protected]"

Snapshot:


Ed25519: The Modern Default

Overview: Ed25519 (EdDSA on Curve25519) is fast, secure, and simple. Default in OpenSSH since v9.4.

When to use it:

Generate your key:

ssh-keygen -t ed25519 -a 100 -C "[email protected]"

How it works (high‑level):

  1. Derive a 256‑bit scalar from your seed (SHA-512 + clamp).
  2. Sign with a deterministic nonce (no RNG headaches).
  3. Verify with a single point‑mul and addition.

Security & Performance:


TL;DR & Next Steps

Action Item:

rm ~/.ssh/id_{rsa,ecdsa}*
ssh-keygen -t ed25519 -a 100 -C "new-key@$(hostname)"

For more detailed SSH notes, visit my GitHub.