Created
March 30, 2017 16:44
-
-
Save techdad/e54927b20e5ea0d7054c1df5ad2d145c to your computer and use it in GitHub Desktop.
TSIG (or nsupdate) key generation, take two (improved)
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 | |
# version 2 | |
# mostly taken directly from https://github.com/Neilpang/acme.sh/tree/master/dnsapi | |
# (with a sprinkle of added command-line switching) | |
# define key params | |
size="512" | |
algo="hmac-sha$size" | |
# get key name | |
if [[ -z $1 ]]; then | |
echo "Error: Usage: $0 <key-name>" | |
exit 1 | |
else | |
keyname="$1" | |
fi | |
tsig=$(dnssec-keygen -a $algo -b $size -n USER -K /tmp $keyname) | |
cat <<EOF | |
key "$keyname" { | |
algorithm $algo; | |
secret "$(awk '/^Key/{print $2}' /tmp/$tsig.private)"; | |
}; | |
EOF | |
rm -f /tmp/$tsig.{private,key} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment