2 # Script to convert SSHFP Bind format records to djbdns tinydns.
4 # Author: Elan Ruusamäe <glen@pld-linux.org>
6 # Inspired from Perl version
7 # http://dank.qemfd.net/dankwiki/index.php/SSHFP
9 # convert decimal to octal
11 echo "ibase=10; obase=8; $1" | bc -l
14 # convert hex to octal
16 # bc wants uppercase hex
17 local i=$(echo "$1" | tr [a-f] [A-F])
18 echo "ibase=16; obase=8; $i" | bc -l
22 ssh-keygen -f /etc/ssh/ssh_host_rsa_key.pub -r $hostalias | \
23 while read host in sshfp alg fptype fp; do
24 out="\\"$(printf "%03d" $(dec2oct $alg))
25 out=$out"\\"$(printf "%03d" $(dec2oct $fptype))
28 # temp chop off two bytes
32 out=$out"\\"$(printf "%03d" $(hex2oct $ch))
36 printf ":%s:44:%s:\n" $host $out