Created
May 7, 2016 03:41
-
-
Save zygiss/b6caf37d4d8553b0d26b5b44c997df0a to your computer and use it in GitHub Desktop.
Quick script to prepare SSHFP DNS records on a host
This file contains 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/sh | |
# https://www.iana.org/assignments/dns-sshfp-rr-parameters/dns-sshfp-rr-parameters.xhtml | |
set_sha() { | |
if [ "`uname -s`" = "Linux" ]; then | |
sha="sha${fp_algo}sum" | |
else | |
sha="sha${fp_algo}" | |
fi | |
} | |
gen_fp() { | |
pk_algo=$1 | |
fp_algo=$2 | |
case $pk_algo in | |
"rsa") pk_value=1 ;; | |
"ecdsa") pk_value=3 ;; | |
"ed25519") pk_value=4 ;; | |
esac | |
case $fp_algo in | |
1) fp_value=1 ;; | |
256) fp_value=2 ;; | |
esac | |
file="/etc/ssh/ssh_host_${pk_algo}_key.pub" | |
echo -n "SSHFP $pk_value $fp_value " | |
set_sha | |
awk '{ print $2 }' $file | openssl base64 -d -A | $sha | tr '[:lower:]' '[:upper:]' | awk '{ print $1 }' | |
} | |
for pk_algo in rsa ecdsa ed25519 ; do | |
for fp_algo in 1 256 ; do | |
gen_fp $pk_algo $fp_algo | |
done | |
done |
Author
zygiss
commented
May 7, 2016
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment