Skip to content

Instantly share code, notes, and snippets.

@oskar456
Last active April 15, 2022 19:48
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save oskar456/623318eeb46c602e9cbf to your computer and use it in GitHub Desktop.
Save oskar456/623318eeb46c602e9cbf to your computer and use it in GitHub Desktop.
Generate remotely SSHFP records
#!/bin/bash
set -e
if [[ "$#" -lt 1 ]]; then
echo "Usage: $0 <hostname or IP address>"
exit
fi
host="$1"
for proto in rsa ecdsa ed25519; do
ssh-keyscan -t $proto "$host" 2>/dev/null |
sed -r 's/^[^ ]+ //' |
ssh-keygen -r "$host" -f /dev/stdin 2>/dev/null |
sed -rn 's/^([^ ]+) IN SSHFP ([1,3-9] [2-9] .*)$/\t\tIN\tSSHFP\t\2/p'
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment