SSHFP record

On this page 7

An SSHFP record (SSH fingerprint record) is a DNS resource record that publishes a cryptographic fingerprint of a server’s SSH host key, allowing an SSH client to verify the server’s identity through DNS instead of asking the user to accept an unknown key. Among DNS records, it belongs to the family that binds security material to a domain name, alongside the TLSA record and the CAA record.

The record type was defined in RFC 4255 in 2006 and carries the type code 44. Its value depends entirely on DNSSEC: without signed and validated answers, an attacker who can tamper with DNS could also forge the fingerprint, so the record would add no real protection.

How the SSHFP record replaces trust on first use

By default, SSH relies on trust on first use (TOFU). On the first connection the client shows the host key fingerprint and asks the user to confirm it; the key is then stored in the known_hosts file. Few users actually compare the fingerprint, so the first connection is the moment when a man-in-the-middle attack is easiest.

An SSHFP record moves that check into DNS. The client receives the host key during the SSH handshake, computes its hash, and compares the hash with the SSHFP records of the host name. When the records are signed and the resolver reports a validated DNSSEC answer, a match proves that the key belongs to the server the domain owner intended.

In OpenSSH the behavior is controlled by the client option VerifyHostKeyDNS. The table shows its three settings and their outcomes.

SettingValidated match foundNo match or unsigned answer
no (default)Records are ignoredNormal TOFU prompt
askFingerprint shown as found in DNS, user still confirmsNormal TOFU prompt with a warning on mismatch
yesKey accepted automaticallyPrompt or refusal, depending on mismatch and StrictHostKeyChecking
Effect of the VerifyHostKeyDNS option in OpenSSH

SSHFP record format and field values

The record data has three fields: a key algorithm number, a fingerprint type number and the fingerprint itself in hexadecimal. A typical entry reads host.example.com. IN SSHFP 4 2 abc123..., where 4 identifies an Ed25519 key and 2 identifies a SHA-256 hash.

ValueAlgorithmDefined inCurrent status
1RSARFC 4255Widely deployed
2DSARFC 4255Deprecated and disabled in modern OpenSSH
3ECDSARFC 6594Supported
4Ed25519RFC 7479Recommended for new servers
6Ed448RFC 8709Limited client support
Key algorithm numbers in the first field

The second field selects the hash function. SHA-256 (value 2) is the practical choice, because SHA-1 (value 1) is considered weak against collision attacks and should not be relied on alone.

ValueHash functionHex lengthRecommendation
1SHA-140 charactersPublish only for legacy clients
2SHA-25664 charactersPreferred for all deployments
Fingerprint type numbers in the second field

A server with several host keys normally has one SSHFP record per key and hash combination. The OpenSSH command ssh-keygen -r hostname prints ready-made records for every key on the server, which removes the risk of transcription errors.

SSHFP is one of several records that let DNSSEC act as a distribution channel for trust anchors. Each record answers a different question, and confusing them leads to incomplete protection.

RecordProtectsWhat it carriesRequires DNSSEC
SSHFP recordSSH connectionsHash of the SSH host keyYes, for any security value
TLSA recordTLS services (DANE)Hash or full certificate or keyYes
CAA recordCertificate issuanceAuthorized certificate authoritiesRecommended
DS recordThe DNSSEC chain itselfHash of the child zone’s DNSKEYIs part of DNSSEC
Security-related DNS records and their purposes

An alternative to SSHFP is an SSH certificate authority, where hosts carry certificates signed by an internal CA key and clients trust that key. Certificates scale well inside one organization, while SSHFP works across organizational boundaries for anyone who can query the public zone.

Deploying SSHFP records safely

A reliable deployment needs three conditions at once: the zone must be signed, the client’s resolver must validate signatures, and the client must trust the resolver’s validation result. The third condition is often overlooked, because a stub resolver on the client typically only reads the AD (authenticated data) flag set by an upstream validating resolver.

  • Sign the zone with DNSSEC and confirm the DS record at the parent before relying on SSHFP.
  • Use a validating resolver on the host itself or on a trusted local network path, not an untrusted public network.
  • On glibc systems, the AD flag is passed to applications only when options trust-ad is set in the resolver configuration.
  • Regenerate records after key rotation, because a stale fingerprint causes a mismatch warning or a refused connection.
  • Remove obsolete records for retired algorithms such as DSA to keep the record set clean.

The record can be published in any zone, including private or split-horizon views, provided internal clients query a validating resolver for that view.

Limitations and common mistakes

The most common error is publishing SSHFP in an unsigned zone and enabling VerifyHostKeyDNS yes. OpenSSH then treats the result as insecure and falls back to the prompt, so the record gives a false sense of protection without changing behavior.

Other limitations are structural. SSHFP identifies a host by name only, so connections made by raw IP address cannot use it, and it gives no protection if the DNS zone or registrar account is compromised. Client support outside OpenSSH also varies, and many graphical SSH tools ignore the record entirely.

In simple terms

When a computer connects to a server over SSH for the first time, it is shown a long code and asked whether that code looks right. Almost nobody checks it, which leaves room for an impostor server.

An SSHFP record puts the correct code in the server’s DNS entry, much like printing an official phone number in a trusted directory. If the directory is protected by digital signatures, the computer can compare the codes itself and connect safely without asking anyone.

A practical example

A university research group runs about forty Linux servers in a DNSSEC-signed zone. New students repeatedly accepted unknown host keys without checking, and a security review flagged this habit as a man-in-the-middle risk.

The administrators run ssh-keygen -r on each server, add the resulting Ed25519 and RSA records with SHA-256 fingerprints to the zone, and distribute a client configuration with VerifyHostKeyDNS yes. Lab workstations use a validating Unbound resolver on the campus network. After the change, first connections succeed without any fingerprint prompt, and a deliberate test with a replaced host key produces an immediate warning. The group also adds a step to its key rotation procedure so that records are updated together with the keys.