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.
| Setting | Validated match found | No match or unsigned answer |
|---|---|---|
| no (default) | Records are ignored | Normal TOFU prompt |
| ask | Fingerprint shown as found in DNS, user still confirms | Normal TOFU prompt with a warning on mismatch |
| yes | Key accepted automatically | Prompt or refusal, depending on mismatch and StrictHostKeyChecking |
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.
| Value | Algorithm | Defined in | Current status |
|---|---|---|---|
| 1 | RSA | RFC 4255 | Widely deployed |
| 2 | DSA | RFC 4255 | Deprecated and disabled in modern OpenSSH |
| 3 | ECDSA | RFC 6594 | Supported |
| 4 | Ed25519 | RFC 7479 | Recommended for new servers |
| 6 | Ed448 | RFC 8709 | Limited client support |
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.
| Value | Hash function | Hex length | Recommendation |
|---|---|---|---|
| 1 | SHA-1 | 40 characters | Publish only for legacy clients |
| 2 | SHA-256 | 64 characters | Preferred for all deployments |
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 compared with related security records
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.
| Record | Protects | What it carries | Requires DNSSEC |
|---|---|---|---|
| SSHFP record | SSH connections | Hash of the SSH host key | Yes, for any security value |
| TLSA record | TLS services (DANE) | Hash or full certificate or key | Yes |
| CAA record | Certificate issuance | Authorized certificate authorities | Recommended |
| DS record | The DNSSEC chain itself | Hash of the child zone’s DNSKEY | Is part of DNSSEC |
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-adis 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.