
When configuring passwordless SSH authentication for GitHub, GitLab, AWS, or Linux production servers, engineers consistently ask: Should I generate an Ed25519 key (ssh-keygen -t ed25519), an RSA-4096 key, or an ECDSA key? Building on our foundational What Is Secure Shell (SSH)? Architecture Guide, this hands-on reference compares the cryptographic math, wire performance, and side-channel resistance of Ed25519 (IETF RFC 8709) against RSA (RFC 8332) and ECDSA (RFC 5656)—and provides an interactive multi-OS command generator for Windows PowerShell, macOS, and Linux.
Interactive Multi-OS SSH Keygen (`Ed25519` / `FIDO2-SK`) & Config Builder
Select your operating system, key algorithm, and target host to generate the exact key-generation, SSH-agent registration, and ~/.ssh/config commands.
Ed25519 vs. RSA-4096 vs. ECDSA: Cryptographic & Performance Comparison
| Property | Ed25519 (Edwards-curve DSA) | RSA-4096 (SHA-256 / SHA-512) | ECDSA (nistp256 / secp256r1) |
|---|---|---|---|
| IETF Specification | RFC 8709 / RFC 8032 | RFC 8332 (Note: legacy ssh-rsa SHA-1 is deprecated) | RFC 5656 / FIPS 186-5 |
| Public Key Wire Size | 32 bytes (256 bits) — 68-char Base64 string | 512 bytes (4,096 bits) — 720+ char Base64 string | 64 bytes (uncompressed point) |
| Deterministic Nonce Safety | Yes (Deterministic SHA-512 hash) — immune to weak RNG | Yes (Deterministic PKCS#1 v1.5 padding) | No (Unless RFC 6979 is enforced; a single reused k nonce leaks the private key) |
| Side-Channel Timing Immunity | Complete constant-time ladder (no secret branch conditions) | Requires blinding to prevent timing leaks | Implementation-dependent |
Why the -a 100 Flag Matters: Hardening Your Private Key with 100 bcrypt-pbkdf Rounds
When you generate an Ed25519 key with a passphrase, OpenSSH stores the private key in the OPENSSH PRIVATE KEY container format encrypted with bcrypt-pbkdf. Passing -a 100 increases the key-derivation iteration count to 100 rounds, adding roughly 0.4 seconds to interactive key unlocking while making offline GPU dictionary attacks against a stolen laptop’s ~/.ssh/id_ed25519 file orders of magnitude more expensive. For hardware-bound zero-trust authentication, see our Passkeys vs. Password Managers & Hardware FIDO2 Guide.
First Principles: What Actually Separates Ed25519, RSA, and ECDSA
An SSH key pair is not one thing but three coupled decisions: a mathematical group (the curve or modulus), a signature scheme (how a message is transformed into a proof of possession), and an encoding (how that proof travels over the wire). Most real-world SSH incidents are failures in the third layer or in key storage, not in the underlying hardness assumption. Understanding the three families at the level of their defining RFCs makes the operational recommendations later in this article derivable rather than arbitrary.
The comparison map is as follows. Ed25519 is specified for SSH in RFC 8709, defining the ssh-ed25519 public key format and its use inside signatures exchanged during authentication. RSA is governed by RFC 4253‘s original ssh-rsa type and updated by RFC 8332, which added the SHA-2 signature variants rsa-sha2-256 and rsa-sha2-512 — critical because the legacy ssh-rsa identifier implies SHA-1 hashing, which modern OpenSSH disables by default since release 8.8. ECDSA for SSH comes from RFC 5656, which standardizes signatures over the NIST curves P-256, P-384, and P-521 under the key types ecdsa-sha2-nistp256, -nistp384, and -nistp521.
The Curve Mathematics: Twisted Edwards vs. Weierstrass vs. Integer Factorization
Ed25519 operates on a twisted Edwards curve of the form:
-x^2 + y^2 = 1 + d*x^2*y^2 (mod p), where p = 2^255 - 19
For Ed25519 specifically:
d = -121665/121666 mod p
Base point order l = 2^252 + 27742317777372353535851937790883648493Every twisted Edwards curve is birationally equivalent to a Montgomery curve — and in this case, to Curve25519, the same curve used for X25519 ephemeral Diffie-Hellman key exchange. The birational map means each rational point on one curve corresponds exactly to a point on the other (except finitely many exceptional points), so a deployment can reuse the same finite-field arithmetic across both its key-exchange layer (X25519) and its signature layer (Ed25519). This is more than elegance: the complete addition formulas over twisted Edwards curves are exceptionally fast because they never branch into special cases — every point addition costs the same sequence of field multiplications regardless of input coordinates, which eliminates timing side channels that Weierstrass-form implementations must actively defend against.
The underlying field GF(2^255 − 19) uses pseudo-Mersenne primes: reduction modulo 2^255 − 19 needs only a shift and a few additions, since 2^256 ≡ 19 mod p. Compare this with P-256’s prime, which is close to but not exactly a power of two, forcing generalized Montgomery-style reduction. This single choice accounts for much of Ed25519’s roughly 3–5x signing-speed advantage over NIST-curve ECDSA at comparable security levels in portable software implementations.
NIST P-256/P-384 from RFC 5656 use short-Weierstrass form:
y^2 = x^3 + ax + b (mod p), with a = -3 typicallyPoint arithmetic here requires projective coordinates and careful handling of edge cases (point doubling when Y = 0, exceptional infinities). RSA, by contrast, does not live on an elliptic curve at all — its security rests on the difficulty of factoring a large semiprime n = p*q, with signatures computed as s = m^d mod n using the Chinese Remainder Theorem across the private half-primes for speed. Its security-per-bit ratio is the worst of the three: a 3072-bit RSA modulus delivers roughly the same ~128-bit security margin as a 256-bit point on Ed25519 or P-256.
Deterministic Nonces: Why Ed25519 Cannot Leak Your Key the Way ECDSA Can
The most practically important difference between the schemes is how each generates the per-signature nonce k. In ECDSA, signing requires choosing a random scalar k, computing k·G, and emitting r and s values derived from it. If any two distinct messages are signed with the same k — even once — the private key falls out immediately via:
Given (r, s1) for m1 and (r, s2) for m2 sharing nonce k:
k = (m1 - m2) / (s1 - s2) (mod n)
d = (s1*k - m1) / r (mod n)Even a few bits of bias in an otherwise non-repeated k suffices; lattice attacks over many signatures recover keys from partial leaks, as demonstrated historically across multiple embedded-device deployments. An SSH client that relies on a weak entropy source — a real risk on freshly imaged VMs, embedded routers, and constrained IoT agents — can therefore hand attackers its long-term identity.
Ed25519 eliminates this failure mode by construction. The nonce is deterministically derived as the hash of the private seed and the message itself:
nonce = SHA-512(seed[32..63] || prefix_of_message_hash)[first 64 bytes] mod lThe first half of the SHA-512 digest of the seed forms the message hash prefix; the second half drives nonce generation. Repeating a signature produces the identical (benign) output rather than a catastrophic (r, s) collision, and no random number generator participates in signing at all. This makes Ed25519 uniquely suitable for environments where RNG quality cannot be audited — CI runners, containers, air-gapped signers, and hardware tokens with limited entropy pools.
The Wire Format: How Each Algorithm Actually Appears on the Network
During authentication, the client sends a SIG_RSA / SIG_KEX_-style signed blob per RFC 4252’s publickey method. What differs between algorithms is the key blob layout defined by their respective RFCs:
- RFC 8709 (ssh-ed25519): the blob is simply a string containing the 32-byte little-endian encoded point A. There are no parameters to negotiate, no curve-name field, nothing to misconfigure. The signature itself is a single 64-byte packed (R ‖ S) pair — compact and fixed-length.
- RFC 8332 (rsa-sha2-512): the blob carries the modulus n as an mpint plus the exponent e. Signature length scales with the modulus (384 bytes at 3072 bits, 512 bytes at 4096), and the hash-algorithm identifier must match between the advertised algorithm name and the actual digest — mismatched advertisement of
ssh-rsawhen SHA-2 was intended is among the most common interoperability failures in heterogeneous fleets. - RFC 5656 (ecdsa-sha2-nistp256/384/521): the blob contains a curve-name string plus the Q-point, and the signature is two mpints (r, s). Implementations must validate that Q lies on the named curve; skipping this validation historically enabled invalid-curve attacks against several SSH client libraries.
Negotiation and Post-Quantum Key Exchange
Modern hardening starts not at the key pair but at the transport layer. A current production /etc/ssh/sshd_config should pin algorithms explicitly so that version drift across your fleet cannot silently downgrade negotiation:
# /etc/ssh/sshd_config — modern baseline
KexAlgorithms sntrup761x25519-sha512@openssh.com,curve25519-sha256,curve25519-sha256@libssh.org
Ciphers chacha20-poly1305@openssh.com,aes256-gcm@openssh.com,aes128-gcm@openssh.com
MACs umac-128-etm@openssh.com,hmac-sha2-512-etm@openssh.com
PubkeyAcceptedAlgorithms ssh-ed25519-cert-v01@openssh.com,ssh-ed25519,rsa-sha2-512,rsa-sha2-256
HostKeyAlgorithms ssh-ed25519,rsa-sha2-512
AuthenticationMethods publickey
PasswordAuthentication no
PermitRootLogin prohibit-password
UsePAM yes
# On the client side, mirror it in ~/.ssh/config:
# PubkeyAcceptedAlgorithms +rsa-sha2-512 (only if legacy RSA servers remain)The sntrup761x25519-sha512@openssh.com key exchange pairs the NTRU Prime post-quantum encapsulation with X25519 in a hybrid construction — the session key derives from both secrets, so an attacker must break classical ECDH now or the lattice problem later. It has been OpenSSH’s default KEX since 9.0 and adds roughly one kilobyte per handshake, negligible on any modern link.
Key Storage: The OpenSSH Private Key Container and bcrypt-pbkdf
Since OpenSSH 6.5, private keys are stored in the openssh-key-v1 container rather than raw PEM. The format is:
"openssh-key-v1 " || ciphername || kdfname || kdfopts ||
number_of_keys || [public_key_blob]... ||
[encrypted_padded_private_payload]...
Inside the payload: checkint1, checkint2 (random, equal),
then algorithm-specific fields; padding to cipher block size with
bytes 1..n.When a passphrase is set, the container uses bcrypt-pbkdf, a KDF that runs bcrypt over the passphrase plus salt and feeds the output through further iterations to derive both the encryption key and IV for AES-256-CTR (default cipher aes256-ctr). The -a flag of ssh-keygen controls the number of rounds — each unit multiplies the brute-force cost linearly. Default is 16; a generation command like:
ssh-keygen -t ed25519 -a 100 -C "workstation-alice-2026"
# -a 100 → 100×16 = 1600 bcrypt rounds inside the KDF setup
ssh-keygen -t rsa -b 4096 -a 64 -o -C "legacy-server-access"raises offline attack cost on a stolen file substantially. On typical consumer hardware, unlocking a -a 100 key costs tens of milliseconds per use versus microseconds for raw parsing — imperceptible interactively, punishing for dictionary attacks at scale. Note that keys with no passphrase are still wrapped in the v1 container but with none as the KDF; they offer zero at-rest protection and should live only on encrypted volumes or inside agent forwarding scenarios.
Hardware-Resident Keys: FIDO2 and ***@openssh.com
OpenSSH 8.2 introduced security-key-backed keys under two types: sk-ecd...p256@openssh.com (mandatory on early token firmware) and ***@openssh.com (supported by firmware 5.2.3+). The private key never leaves the authenticator’s secure element — the token computes the signature when touched, and the “key” you store on disk is really a public half plus a key-handle blob the token can resolve back to its internal secret.
# Create a resident (discoverable) credential requiring physical touch:
ssh-keygen -t ed25519-sk -O resident -O verify-required
-C "alice-fido-titan-or-yubikey"
# List resident credentials stored on the token:
ssh-keygen -K
# writes id_ed25519_sk files extracted from the hardware
# Per-host options in ~/.ssh/config:
# Host production.example
# IdentityFile ~/.ssh/id_ed25519_sk
# SecurityKeyProvider /usr/lib/openssh/***
# PublicKeyAuthentication yesThe flags matter operationally. -O resident stores the credential on the token itself so it survives across machines without copying files — plug into any host, run ssh-keygen -K, and the identity follows you. -O verify-required forces PIN entry at authentication time even for non-resident use, adding a second factor beyond possession. -O touch-required (implied by default) enforces user presence. The signature returned is still Ed25519 or NIST-P256 as negotiated; nothing changes server-side except that the accepted-algorithms list must include the sk- prefixed types when such keys are authorized.
Empirical Comparison: Key Generation, Signature Cost, and Size
| Property | Ed25519 (RFC 8709) | RSA-SHA2-512 (RFC 8332) | ECDSA P-256 (RFC 5656) |
|---|---|---|---|
| Security level | ~128-bit | 3072-bit ≈ 112–128; 4096 ≈ ~130 | ~128-bit |
| Public key blob size | ~51 bytes (51 + overhead) | 384 B @3072 / 512 B @4096 (n) + e | ~65 B point + curve name |
| Signature size | 64 bytes, fixed | Modulus-length (variable) | Two ~32-byte scalars (~70 B packed) |
| Key generation time (typical laptop CPU) | <10 ms | 0.5–3 s @3072 / 2–15 s @4096 (prime search variance) | ~5–20 ms |
| Signing throughput, portable software | Baseline fastest (tens of thousands/s class) | Slowest (single CRT-modexp dominated) | 3–5x slower than Ed25519 in generic C |
| Nonce failure mode | Deterministic SHA-512 — none | Not applicable (deterministic scheme) | k-reuse / bias → private key recovery |
| Entropy dependence at sign-time | Low (seed only) | High (prime gen at creation; blinding optional) | Critical (every signature) |
| Side-channel posture in clean implementations | Complete addition formulas, no branches | Requires CRT blinding against fault/timing leaks | Requires constant-time scalar mult care |
| Generation command | Platform notes (Windows / macOS / Linux) |
|---|---|
| Identical syntax everywhere: Windows 10/11 ships OpenSSH as an optional feature (ssh-keygen.exe in System32OpenSSH), macOS bundles it, and every mainstream Linux distro includes it. |
| Use only where legacy servers mandate RSA; pair with rsa-sha2-512 client-side. |
| Reserved for FIPS-constrained environments that cannot ship Ed25519. |
| Windows requires a libfido2.dll on PATH (bundled in recent OpenSSH for Windows builds); macOS needs nothing extra since Monterey-era tokens work natively via IOKit/HID; Linux needs *** and udev rules granting HID access to the token. |
Certificates, Rotation, and Revocation: Operating Keys at Fleet Scale
A long-lived authorized_keys file is an audit liability. OpenSSH certificates replace per-host trust lists with short-lifetime signed assertions issued by a certificate authority:
# CA side — generate once, guard offline:
ssh-keygen -t ed25519 -f /etc/ssh/ca_key -C "ssh-ca-production"
# Issue a user cert valid 52 weeks, restricted to one principal:
ssh-keygen -s /etc/ssh/ca_key
-I "alice-workstation-2026H1"
-n alice
-V +52w
-z 1001
~/.ssh/id_ed25519.pub
# → id_ed25519-cert.pub
# Host side trusts only the CA, not individual keys:
echo "@cert-authority * $(cat /etc/ssh/ca_key.pub)" >> /etc/ssh/ssh_user_caThe -V +52w validity window forces rotation as a natural consequence of expiry rather than a calendar reminder; -z assigns a serial for logging. For host identity, use @cert-authority entries in known_hosts so clients stop pinning individual host keys and instead verify a chain to your infrastructure CA.
Revocation: AuthorizedRevokedKeys and Key Revocation Lists
Compromised keys are neutralized two ways. The quick path is appending the offending key or certificate (or any substring-matched pattern) to /etc/ssh/sshd_config‘s revocation target:
# sshd_config:
AuthorizedKeysFile .ssh/authorized_keys
RevokedKeys /etc/ssh/revoked_keys # plain list: one key/cert per line
# A proper KRL supports compact binary revocation by serial or hash:
ssh-keygen -k -f /etc/ssh/revoked.krl ~/.ssh/id_ed25519.pub
ssh-keygen -uk -f /etc/ssh/revoked.krl -s 1001 id_to_revoke-cert.pub
sshd -t && systemctl reload ssh # always syntax-check before reloadKRLs support revoking certificates by serial number or key ID without possessing the public key itself, which matters when the compromised cert’s blob has already been purged from your inventory. Rotation discipline follows directly: generate on-device (never transport a private half), push only the public blob, test with a second terminal session open, then revoke the predecessor via KRL — achieving zero shared-secret overlap between identity generations.
Decision Matrix
| Scenario | Recommended algorithm | Rationale |
|---|---|---|
| Interactive human login, all modern servers | Ed25519, -a 100 | Fastest generation and signing; deterministic nonces remove RNG risk. |
| High-assurance or shared workstations | ***@openssh.com with -O resident -O verify-required | Private half never leaves hardware; presence + PIN enforced. |
| Legacy appliances / older SSH servers (pre-6.5) | RSA 4096 via rsa-sha2-512, SHA-1 advertised type disabled | Only option where Ed25519 unsupported; still cryptographically sound at modern sizes. |
| FIPS-mandated environments | ECDSA P-384/P-521 or RSA ≥3072 | Compliance frameworks historically validate NIST curves first; Ed25519 adoption in such regimes is gradual, not absolute — verify your framework’s current stance. |
| Fleet-wide automation / CI | Ed25519 certs via SSH CA, -V +52w | Expiry-driven rotation; no authorized_keys sprawl; instant KRL revocation. |
Three takeaways summarize the engineering case. First, Ed25519 wins on every measurable axis — generation latency, signature size, signing throughput, entropy resilience, and implementation simplicity — which is why it is the default recommendation wherever both endpoints support RFC 8709. Second, RSA remains legitimate at ≥3072 bits strictly under SHA-2 names (rsa-sha2-512, never legacy ssh-rsa) for compatibility with older targets. Third, ECDSA over NIST curves is best treated as a compliance bridge rather than a first choice: its security rests entirely on per-signature nonce quality that software cannot prove and hardware tokens must be trusted to maintain. Layered on top of all three, hybrid post-quantum key exchange via sntrup761x25519-sha512@openssh.com, bcrypt-pbkdf-hardened private containers, resident FIDO2 credentials for interactive use, and certificate-based issuance with short validity windows convert a good key algorithm into an operable, auditable identity system.
Written and prepared by Kshitij Gupta.



