Created
May 15, 2023 16:53
-
-
Save Zash/6a84139173a6f098b6f69c7353d28c73 to your computer and use it in GitHub Desktop.
Update SSHFP records
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/bash | |
set -eo pipefail | |
ZONE="$(hostname -d)" | |
FQDN="$(hostname -f)" | |
UPDATES="$(mktemp --suffix .nsupdate)" | |
trap 'rm -- "$UPDATES"' EXIT | |
{ | |
echo "server $(dig +noall +short "$ZONE" soa | cut -d' ' -f1)" | |
echo "zone $ZONE" | |
echo "ttl 3600" | |
echo "del $FQDN IN SSHFP" | |
ssh-keygen -r "$FQDN" | sed 's/^/add /' | |
echo "show" | |
echo "send" | |
echo "answer" | |
} > "$UPDATES" | |
if [ -f "$HOME/.config/nsupdate/$ZONE.key" ]; then | |
nsupdate -k "$HOME/.config/nsupdate/$ZONE.key" "$UPDATES" | |
else | |
cat "$UPDATES" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment