The short answer

An SSHFP record (RFC 4255) holds a hash of one of a server's SSH host keys, published at the server's name. An OpenSSH client with VerifyHostKeyDNS turned on looks it up and compares it with the key the server presents. If the record matches and the answer was validated with DNSSEC, the client can trust the key without asking you. Without DNSSEC, an attacker who can tamper with DNS could forge the record too, so clients only treat it as a hint. Generate the records on the server with ssh-keygen -r, publish them in a DNSSEC-signed zone, and publish the new record before you change a host key.

What the record contains

host.example.com.  3600  IN  SSHFP  4 2 3F2A9C6E1B7D4A5F8E0C2B9D6A1F3E7C5B8D0A2F4E6C9B1D3A5F7E0C2B4D6A8F
FieldValueMeaning
Algorithm1 RSA, 2 DSA, 3 ECDSA, 4 Ed25519, 6 Ed448The type of host key the fingerprint is for
Fingerprint type1 SHA-1, 2 SHA-256The hash used. Publish SHA-256; SHA-1 is kept only for very old clients.
FingerprintHexadecimalThe hash of the public host key (64 hex characters for SHA-256). The value above is an example.

A server usually has several host keys (Ed25519, ECDSA, RSA), so it publishes several SSHFP records at the same name, one per key and hash type. The client only needs one of them to match the key it receives. DSA keys are disabled in current OpenSSH; remove their records.

Why DNSSEC is required

SSHFP moves trust from "the user clicked yes" to "DNS said so". That is only an improvement if the DNS answer cannot be forged. OpenSSH accepts a matching SSHFP record as proof only when the answer is marked as DNSSEC-validated:

  • The zone must be signed, with a working chain of trust from the parent.
  • The client must use a validating resolver that sets the AD (authenticated data) flag, and the path to that resolver must be trusted, ideally a resolver on the same machine.
  • On Linux with glibc 2.31 or later, the stub resolver drops the AD flag unless options trust-ad is set in /etc/resolv.conf (systemd-resolved sets it on its local stub).

If the record matches but the answer was not validated, OpenSSH says it found a matching fingerprint in DNS and still asks you to confirm.

Generating, publishing and checking

StepCommand
Print SSHFP records for every host key, on the serverssh-keygen -r host.example.com
Print the record for one keyssh-keygen -r host.example.com -f /etc/ssh/ssh_host_ed25519_key.pub
Check the published recordsdig +short SSHFP host.example.com
Check the answer validatesdig +dnssec SSHFP host.example.com and look for the ad flag
Connect using DNS verificationssh -o VerifyHostKeyDNS=yes host.example.com
See what the client decidedssh -v -o VerifyHostKeyDNS=yes host.example.com and look for lines about DNS fingerprints

Publish the records in the zone that holds the server's name, exactly as printed (owner name, algorithm, type, fingerprint). Set VerifyHostKeyDNS yes for the hosts that need it in the client's ssh_config, rather than globally, until you know every host has records.

Rotating a host key safely

  1. Generate the new host key on the server but do not remove the old one yet.
  2. Publish SSHFP records for the new key alongside the old ones and wait at least the record's TTL.
  3. Switch the server to offer the new key. OpenSSH can announce new keys to clients with UpdateHostKeys, which also updates known_hosts.
  4. Remove the old key and its SSHFP records once clients have moved over.

Rebuilding a server from an image creates new host keys. Make the build publish fresh SSHFP records, or the first connection will fail verification.

Limits

  • SSHFP only helps for names. Connecting by IP address, or through an alias the zone does not cover, has nothing to look up.
  • It changes how known_hosts is used. With VerifyHostKeyDNS=yes, OpenSSH trusts any key that matches a DNSSEC-validated SSHFP record, even one that differs from the key already in known_hosts, without a key-change warning and without necessarily saving it. Whoever can edit your signed zone can then change which host keys clients accept, so protect DNS write access as carefully as the host keys.
  • Many SSH clients other than OpenSSH ignore SSHFP.
  • Organizations with many servers often use SSH certificates signed by an internal CA instead, which avoid per-host DNS records altogether.
  • Publishing SSHFP reveals that a name runs SSH, which a port scan would show anyway.

How DNS Panopticon helps

Zone Analyzer shows SSHFP records in an uploaded zone export (live scans do not query SSHFP, so check a published record with the dig command above), and Security Posture checks whether the domain is DNSSEC-signed and validates, which SSHFP depends on. DNS Panopticon does not connect to SSH servers or compare fingerprints with live host keys; use the ssh -v check above for that.

FAQ

Do SSHFP records work without DNSSEC?

Only as a hint. OpenSSH will tell you it found a matching fingerprint in DNS, but it still asks you to accept the key, because an unsigned answer could have been forged.

Which fingerprint type should I publish?

SHA-256, type 2. Add SHA-1 records only if you still have very old clients that need them.

Do I need a record for every host key?

It is best to publish one for each key the server offers, since different clients may negotiate different key types. One matching record is enough for a connection.

Does SSHFP replace known_hosts?

Not exactly. Keys you accept by hand still go into known_hosts, but with VerifyHostKeyDNS=yes OpenSSH also trusts any key that matches a DNSSEC-validated SSHFP record, without a key-change warning and without necessarily saving it. DNS then helps decide which host keys are trusted.

Sources and further reading