I have an entry from an OpenSSH known_hosts
file; I'd like to generate an SSHFP resource record for this. I can use ssh-keygen
to generate the fingerprint with no difficulty:
$ ssh-keygen -f foo_known_host -l
1040 09:a0:5c:5f:43:fb:e5:25:d8:0c:d8:dc:d7:7a:c4:62 foo.example.com. (RSA)
But it doesn't seem to like it for a DNS fingerprint record:
$ ssh-keygen -f foo_known_host -r foo
failed to read v2 public key from foo_known_host.
So how do I do this?
Note: If you came here via asking a search engine how to generate an SSHFP record from a remote host (not a local copy of the fingerprint as above), that's done via ssh-keyscan -D machine.name –
.
ssh-keygen(1)
doesn't behave the same way assshfp(1)
.You'll note from the man page that the syntax is:
So the file should be an
input_keyfile
rather than aknown_hosts_file
. If you don't specify then it will default to the server's local keys of/etc/ssh/ssh_host_rsa_key.pub
and/etc/ssh/ssh_host_dsa_key.pub
.You can either generate the record from each server that you wish to create SSHFP records for with
ssh-keygen
. Or sourcesshfp
and create them all from oneknown_hosts
file.This script is good:
http://brmlab.cz/kb/sshfp.sh
It needs to be run in /etc/ssh, or edit it to cd there before it does it's stuff.
try -r $HOSTNAME as first arguement: