Last active
March 30, 2017 16:26
-
-
Save techdad/0f27c9a260bf56098912 to your computer and use it in GitHub Desktop.
gen-tsig.sh
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
#!/usr/bin/env bash | |
# quick and dirty TSIG generation script | |
# define key params | |
algo="hmac-sha512" | |
size="512" | |
# get key name | |
if [[ -z $1 ]]; then | |
echo "Error: Usage: $0 <key-name>" | |
exit 1 | |
else | |
keyn="$1" | |
fi | |
# use generate has for our secret | |
dnssec-keygen -a ${algo} -n host -b ${size} ${keyn} | |
# extract to bind9 format | |
grep "Key" K${keyn}.+*.private | \ | |
awk -v keyn="$keyn" -v algo="$algo" \ | |
'{print "key " keyn " {\n\talgorithm " algo ";\n\tsecret \"" $2 "\";\n};"}' \ | |
> ${keyn}.key | |
# optionally uncomment to delete tmp files | |
# rm -fv K${keyn}.+*.* | |
# eof |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment