Last active
September 16, 2015 10:59
-
-
Save stemid/892fc4d51f13f0241970 to your computer and use it in GitHub Desktop.
sshfp to generate SSHFP records for ecdsa.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# {{ ansible_managed }} | |
# | |
# rewritten from http://blog.chr.istoph.de/dns-sshfp-record-fuer-alle-algorithmen-gleichzeitig-erstellen/ | |
# | |
# Create SSHFP records from public keys, supports ecdsa too. | |
# [email protected] added support for alternate config dirs. 2015-11-16 | |
domain="$1" | |
config_dir="${2:-/etc/ssh}" | |
if [ -z "$domain" ]; then | |
echo "Usage: $0 domain [config_dir]" | |
exit 0 | |
fi | |
function sshfp() { | |
a=$1 #algorithmus | |
f=$2 #file | |
echo $domain IN SSHFP $a 1 $(cut -d' ' -f2 $f|base64 -d|sha1sum|cut -d' ' -f1) | |
echo $domain IN SSHFP $a 2 $(cut -d' ' -f2 $f|base64 -d|sha256sum|cut -d' ' -f1) | |
} | |
for f in "$config_dir"/ssh_host_*_key.pub; do | |
case "$f" | |
in | |
*_rsa_key*) | |
sshfp 1 $f | |
;; | |
*_dsa_key*) | |
sshfp 2 $f | |
;; | |
*_ecdsa_key*) | |
sshfp 3 $f | |
;; | |
*_ed25519*) | |
sshfp 4 $f | |
;; | |
esac | |
done | sort |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment