On this page
What problem do SSHFP records solve?
The first time you connect to a server, SSH shows a key fingerprint and asks whether to trust it. Few people compare that string with anything, so an attacker who intercepts the first connection could slip in their own key. SSHFP records (RFC 4255, with SHA-256 added in RFC 6594) put the fingerprints of the server host keys into DNS. When the zone is signed with DNSSEC and your resolver validates it, the client can confirm the key without asking. This is most useful when you deploy and rebuild servers often, or hand access to people who never saw the server before.
What do I need before I start?
Three things must be true, or the records add nothing:
- An A and AAAA record for the host name, as set up in DNS records.
- DNSSEC on the zone: your DNS host signs it and a DS record sits at the registrar. Without that chain, clients treat SSHFP answers as insecure.
- A validating resolver on each client that passes the authenticated data (AD) flag through to SSH.
Check the zone from any Linux machine with delv, part of bind9-dnsutils on Debian and Ubuntu or bind-utils on Rocky and AlmaLinux:
delv example.net SOAThe answer must start with ; fully validated. If it says unsigned, enable DNSSEC at your DNS host first.
How do I generate the records?
Run ssh-keygen on the server itself, so the values come from the real host keys:
ssh-keygen -r host.example.net
ssh-keygen -r host.example.net | awk '$5 == 2'The first command prints two lines per host key; the second keeps only SHA-256 fingerprints, which is all modern clients need. Each line reads like host.example.net IN SSHFP 4 2 3f1a.... The first number is the key algorithm (1 RSA, 3 ECDSA, 4 Ed25519) and the second the hash type (1 SHA-1, 2 SHA-256). Skip the SHA-1 lines: they are weaker and some validators flag them. If you removed some host key types from sshd, publish only the keys sshd still offers; check with sudo sshd -T | grep hostkey.
How do I publish SSHFP in my zone?
Most DNS hosting panels have an SSHFP record type with three fields: algorithm, fingerprint type and fingerprint. Enter the host label (for example host in the example.net zone) and paste the hex string. If you run your own name server, as in the BIND 9 authoritative DNS guide, add lines like these to the zone file and re-sign it:
host 3600 IN A 198.51.100.24
host 3600 IN AAAA 2001:db8:4f2a::24
host 3600 IN SSHFP 4 2 3f1a0c7e...replace-with-full-hex
host 3600 IN SSHFP 1 2 9be4d21a...replace-with-full-hexUse a moderate TTL such as one hour, so a key change does not take a day to reach clients. Confirm the records are signed:
delv host.example.net SSHFP
dig +dnssec SSHFP host.example.netIn the dig output, the flags line should include ad when your resolver validates.
How do I make the client use DNS fingerprints?
Enable the check in your SSH client configuration for the hosts you publish:
# ~/.ssh/config
Host *.example.net
VerifyHostKeyDNS yesOn Linux the C library drops the AD flag unless the resolver configuration trusts it. With systemd-resolved, the generated /etc/resolv.conf already contains options edns0 trust-ad, but resolved only validates when DNSSEC=yes is set in /etc/systemd/resolved.conf (followed by sudo systemctl restart systemd-resolved). A local validating resolver such as Unbound on 127.0.0.1, with options trust-ad in /etc/resolv.conf, is another solid setup. Setting ask instead of yes shows that DNS matched but still asks you to confirm.
How do I test that it works?
Remove any saved key for the host, then connect with verbose output:
ssh-keygen -R host.example.net
ssh -v deploy@host.example.net 2>&1 | grep -i -E "fingerprint|dns"A working setup prints found 1 secure fingerprints and matching host key fingerprint found in DNS, and you are not asked to confirm the key. If you see insecure fingerprints, the records exist but DNSSEC validation did not reach SSH: check the resolver settings above. A mismatch message means the published record does not match the server key, which you should treat as a real warning until you know why.
What happens when host keys change?
Every new host key needs new records. Reinstalling a server from the Settings tab erases the disk and creates fresh host keys, so publish new SSHFP values right after a rebuild; see reinstalling an image. For a planned rotation, add the new key records next to the old ones, wait at least one TTL, switch sshd to the new keys, and remove the old records afterwards. On the client side, OpenSSH can learn additional host keys for a known server with UpdateHostKeys yes, which pairs well with SSHFP during a rotation.
Is SSHFP a replacement for host certificates?
They solve the same first-contact problem in different ways. SSHFP depends on DNS and DNSSEC and needs no extra files on clients. Host certificates, covered in advanced OpenSSH settings, need one @cert-authority line per client but work for addresses without DNS names and without DNSSEC. Small setups often use SSHFP alone; larger fleets usually prefer certificates and may publish SSHFP as well for people connecting from fresh machines.
Questions about Publish SSH host keys in DNS (SSHFP)
Do SSHFP records reveal anything sensitive?
No. Host key fingerprints are public by design: every client that connects receives the full public key anyway.
Will clients without VerifyHostKeyDNS break?
No. Clients that do not ask for SSHFP ignore the records and fall back to the usual first-connection prompt.
Can I use SSHFP without DNSSEC?
The records will be found but reported as insecure, so SSH still asks you to confirm the key. DNSSEC is what makes them trustworthy.
Do I publish records for every key type?
Publish one SHA-256 record for each host key sshd actually offers, typically Ed25519, ECDSA and RSA. Clients pick the key type they negotiate.
How do I see the fingerprint SSH shows on first login?
Run ssh-keygen -lf /etc/ssh/ssh_host_ed25519_key.pub on the server. It prints the same SHA256 value the client displays.
More in Security
- UFW firewall on Ubuntu and Debian
- firewalld on Rocky Linux and AlmaLinux
- iptables rules that survive a reboot
- Block brute force logins with fail2ban
- CrowdSec intrusion prevention
- Two-factor SSH logins with TOTP
- Disable or restrict root login
- Alerts for every SSH login
- Advanced OpenSSH settings
- Audit open ports with nmap
- File integrity checks with AIDE and Tripwire
- CSF firewall (ConfigServer Security)
- First security steps on Rocky and Alma
- Free TLS certificates with Certbot
- Self-signed certificates and a private CA
- Rate and connection limits in Nginx
- Wazuh security monitoring
- Kernel and sysctl hardening