SSH servers all have fingerprints to identify themselves. These little hashes of the host's public key are exchanged with clients, and remembered in a Trust On First Use (TOFU) security model.
Now, let's be honest. SSH is an incredibly high-value target, but how many of us have actually taken the time to manually verify an SSH key? Raise your hands. Yeah, I'm not raising mine, either.
TOFU is a decent security model, because it protects all connections to the server — except for the very first one.
You might have noticed that there is a line up there that reads,
No matching host key fingerprint found in DNS. Longtime Linux system administrators might know about the SSHFP DNS record, defined way back in RFC 4255. Adding one to a standard DNS server such as BIND9 is as simple as making the records and copying them into your zone file.
If you're lucky enough to be using the BIND DNS server, congratulations! Your work is done. However, if this was all I was writing about, it wouldn't make for a useful article.
However, some of us administer Windows networks, which sometimes means that Active Directory Domain Services (AD DS) is in the mix; and, if that be true, then one would be foolish not to use the Microsoft DNS Server alongside that. Though it lags far behind BIND in terms of feature and resource record support, it does provide a GUI (albeit dated) and a robust PowerShell module.
While it does not support SSHFP records natively, the DNS Server included with all versions of Windows Server will at least accept, store, and serve SSHFP records. The problem, though, is how to get them saved, as neither the GUI nor the PowerShell cmdlets will let you input one. (Neither will
dnscmd, but that thing is deprecated, anyway.)
You might be wondering, though. What is the point of storing SSHFP records when you have a Windows-centric network? Simple: you gain the same benefits.
- If you have macOS or Linux machines on your network, they likely have SSH servers running.
- Your firewall, switches, and VMware hosts might have SSH daemons running, too. Even if they only run some of the time, you can still have DNS-level protection.
- Notably, the OpenSSH Server is an installable feature in Windows 10, Windows 11, Windows Server 2019, and Windows Server 2022; with backports available for downlevel versions. (This may also be the replacement for PowerShell Remoting if WinRM ever becomes deprecated.)
Check Your DNS Server
You will need to be running Windows Server 2012 or later. While this should work with any version of the Microsoft DNS Server, both the RFC — and common sense — strongly recommend you use DNSSEC to secure these records.
If you are running Windows Server 2008 R2 or older, stop right here and evaluate your personal and professional life decisions. Not only has been out of extended support for , but its DNSSEC implementation is rudimentary at best.
Gather Your Fingerprints
You will need to gather the SSH fingerprints for all of your hosts. You can log on and run
ssh-keygen -r to generate them interactively, or for things like printers and other network devices, a tool like
ssh-keyscan can read them remotely.
Download the BIND9 Tools
If you have a macOS or Linux machine with the
nsupdate tool on there, you can skip this section. Otherwise, download the BIND9 Tools for Windows to obtain a copy of
nsupdate.exe, which will allow us to spit arbitrary DNS records into our zone.
Create the NSUpdate Command
nsupdate tool has its own syntax. You can copy and paste all of the hostnames and fingerprints that you've gathered from across your network, and combine them into one big Notepad document.
You can also use this PowerShell to turn your
ssh-keygen -r output into a file that can be used by
nsupdate (here is a barebones example):
Relaxing Zone Security (For a Few Seconds)
Security-conscious people might be thinking that using freeware to inject random DNS records is a very bad thing, and they are correct. Fortunately, by default, Windows-hosted zones default to only allowing secure dynamic updates (authenticated by Kerberos). To accomplish our goal, we will need to temporarily relax security rules.
- In the DNS snap-in, right-click your zone and choose Properties.
- Under Dynamic Updates, choose Secure and Nonsecure.
- Click OK.
Now, don't linger, since we've left our zone open to exploit.
Now for the coup de grâce. You can copy and paste your file directly into
nsupdate.exe. Alternatively, if you've been following along with my PowerShell commands, you can simply do this:
Before you celebrate, we need to restore safety and sanity; either skip back a section and undo your changes, or run this PowerShell command:
Verifying Your Work
Once this is done, you will see some unknown records listed in your list of DNS entries:
Unfortunately, because Microsoft's DNS Server service lags so far behind the curve, you will not be able to edit or properly view the record. Just be happy we got this far. You can, though, double-click on it and view the raw binary data, for what that's worth:
Let's Try It
Now that your SSHFP DNS records are live (and hopefully secured), let's try connecting again. If your records are present and correct, you will see output like this.
It's a bit of a roundabout method, unfortunately. It would be great if Microsoft's DNS Server gave us an easier way to add and modify SSHFP records (and DANE/TLSA records, for that matter). However, this will work, and this will help you secure your internal environment.
Finally, bookmark this page. This isn't a shameless plug, but a warning that, as you replace devices or regenerate SSH host keys, you will need to regenerate your SSHFP records.
- RFC 4255: Using DNS to Securely Publish Secure Shell (SSH) Key Fingerprints
- BIND9 Tools for Windows