skip to content

How would you replace SSH trust-on-first-use for a fleet of servers rebuilt daily, weighing @cert-authority host certificates against SSHFP records in DNS?

level: principalimportance: should knowfreq 14%

answer

  1. prompts nobody reads
  2. trust the signer, not each key
  3. DNS answers need their own proof
  4. the CA becomes the crown jewel

basics

~20 s

Where you control the clients, host certificates usually win: clients pin one CA key with @cert-authority, each rebuilt host gets a freshly signed certificate, and prompts disappear. SSHFP helps only with validated DNSSEC; certificates cost guarding and rotating the CA.

solid answer

~50 s

With daily rebuilds every host key keeps changing, so people learn to accept whatever they see and trust on first use stops protecting anything. One standard replacement is **host certificates**: sign each new host key at provisioning (`ssh-keygen -s` with `-h` and the host names as principals), point sshd at it with `HostCertificate`, and give clients a single `@cert-authority *.internal.example ...` line in a managed known_hosts. The other is **SSHFP** (RFC 4255): publish fingerprints in DNS and set `VerifyHostKeyDNS yes`, which OpenSSH trusts only when the answer is DNSSEC-secure. Where we control the clients I would choose certificates: verification is offline, rebuilds just mean signing, and short validity limits a stolen key. The cost is a CA that is now the fleet's most valuable secret, a signing step in provisioning, and a revocation path (`@revoked`, `RevokedHostKeys`). SSHFP fits clients we do not manage, but only where DNSSEC validation is real.

go deeper

for a junior

Recall that SSH can trust a host because a certificate authority signed its key or because DNS publishes its fingerprint, not only by asking on first connection.

for a middle

Explain how a host certificate, HostCertificate and an @cert-authority line fit together, and why SSHFP needs DNSSEC to mean anything.

for a senior

Plan the rollout: signing at provisioning, revocation lists that never go missing, separate host and user CAs, and narrow host-name patterns per environment.

for a principal

Weigh CA custody and blast radius against DNS dependence and file distribution, decide per client population, and plan CA rotation before you need it.

## Why trust on first use breaks down here Trust on first use (TOFU) assumes keys are stable: you verify once, the client pins the key in `known_hosts`, and any later change is suspicious. A fleet that is rebuilt every day breaks that assumption. Every rebuild produces new host keys, so users and automation see a first-use prompt or a changed-key refusal constantly. People then accept every key, or scripts set `StrictHostKeyChecking no`, and the host-key check, the only server authentication SSH has, is gone. RFC 4251 (section 4.1) names the two ways out: keep a **local database** of name-to-key mappings, or have a **certification authority** vouch for them. In OpenSSH that gives three practical designs. ## Option 1: host certificates An OpenSSH host certificate is the host's public key plus identity, principals and a validity period, signed by a CA key. It is OpenSSH's own simple format, not X.509. 1. Provisioning signs each new host key with the host CA, using `-h` and the host's names as principals; host principals are hostnames and may contain wildcards. 2. sshd is told to present it: ```ini # server configuration on each host HostKey /etc/ssh/ssh_host_ed25519_key HostCertificate /etc/ssh/ssh_host_ed25519_key-cert.pub ``` 3. Clients carry one line in a managed known_hosts file (system-wide default `/etc/ssh/ssh_known_hosts`): `@cert-authority *.internal.example ssh-ed25519 AAAA...`, the CA's public key. A rebuilt host is then trusted the moment it is signed; clients never change. **Revocation** uses `@revoked` lines or a `RevokedHostKeys` file or key revocation list; if that file is configured but unreadable, the client refuses host authentication for all hosts, so distribute it as carefully as the CA line. Short certificate validity reduces how much you rely on revocation at all. ## Option 2: SSHFP records with DNSSEC SSHFP records (RFC 4255) publish host-key fingerprints in DNS. With `VerifyHostKeyDNS yes`, OpenSSH accepts a key without prompting only when the fingerprint arrives in a **DNSSEC-secure** answer; an insecure answer is handled as if the option were `ask`. RFC 4255 itself says a key verified this way must not be trusted unless the record was authenticated. OpenSSH 10.1 also announced that a future release will ignore SHA-1 SSHFP records, so publish SHA-256 fingerprints. ## Option 3: a managed known_hosts of plain keys Distribute every host's actual key to every client. It needs no CA, but daily rebuilds mean the file changes daily and must reach clients before users do. `UpdateHostKeys` does not rescue it: it lets an already-trusted host announce additional keys for graceful rotation, which a freshly rebuilt host with a brand-new key cannot use. ## Comparing the options | Concern | Host certificates | SSHFP + DNSSEC | Managed plain keys | |---|---|---|---| | Client change per rebuild | none | none | new file every time | | Depends at connect time on | nothing online | validating resolver path | file distribution | | Clients you do not manage | need the CA line | work if they validate DNSSEC | need the file | | Compromise of one host key | expire or revoke the certificate | replace the record | push a new file | | Central risk | CA private key | DNS signing keys and zone control | distribution pipeline | ## The judgement - **Who controls the clients?** Engineers' laptops, CI runners and jump hosts under your configuration management can carry a `@cert-authority` line; outside parties usually cannot, which favours SSHFP or published fingerprints for them. - **Is DNSSEC real end to end?** Signed zones are not enough; the client's resolver path must validate. Without that, SSHFP is TOFU from a different source. - **Can you protect the CA?** It now vouches for every host. Keep it offline or in hardware, separate from any user CA, sign from an audited provisioning step, and plan its rotation: ship the new CA line alongside the old one, re-sign hosts, then retire the old line. - **What is the blast radius?** A stolen CA key lets an attacker impersonate any host matching the line's patterns, so scope patterns narrowly per environment. For a fleet you operate and clients you configure, certificates turn daily rebuilds into a non-event and keep the warning meaningful when it does appear.

  • A host's private key is stolen in a certificate-based fleet. How do you stop clients trusting it?
    Add the key or its certificate to a revocation list clients read, as an `@revoked` line in the managed known_hosts or a `RevokedHostKeys` file or key revocation list, then rebuild and re-sign the host. Short certificate validity limits the window even if revocation lags.
  • Why does SSHFP add little without DNSSEC validation?
    An attacker who can intercept the SSH connection can often forge the DNS answer too, so an unauthenticated fingerprint proves nothing. RFC 4255 forbids trusting it, and OpenSSH treats an insecure SSHFP match as `ask`, which brings back the prompt.
  • Does UpdateHostKeys solve the daily-rebuild problem?
    No. It lets a server the client already trusts announce extra or replacement keys during a connection, for graceful rotation on a living host. A rebuilt host presents a key nobody has trusted yet, and OpenSSH applies the mechanism only to hosts authenticated with a plain key from the user's known_hosts, not with a certificate.

  • Setting StrictHostKeyChecking no fleet-wide is a fine fix for rebuild prompts.
  • SSHFP records authenticate a host even when DNSSEC is not validated.
  • SSH host certificates require an X.509 PKI like the one TLS uses.
  • Copy the CA private key to every server so hosts can sign themselves.
  • An @cert-authority line also lets that CA's certificate holders log in.

Assumes OpenSSH 10.5; host certificates and SSHFP verification are long-standing, and 10.1 announced that a future release will ignore SHA-1 SSHFP records.