Created
September 8, 2016 07:12
-
-
Save hotpxl/2fab01912695467d74e04d3bf80bd8fa to your computer and use it in GitHub Desktop.
Get SSHFP record
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 -euo pipefail | |
print_usage() { | |
printf "Usage: %s <fully qualified domain names>...\n" "$(basename "$0")" | |
exit 1 | |
} | |
if [[ "$#" -lt 1 ]]; then | |
print_usage | |
fi | |
signatures=$(ssh-keyscan "$@" 2> /dev/null) | |
if [[ "${signatures}" == "" ]]; then | |
exit 1 | |
fi | |
array=() | |
while IFS= read -r line; do | |
domain=$(echo "${line}" | cut -d " " -f 1) | |
signature=$(echo "${line}" | cut -d " " -f "2-") | |
dns_rr=$(ssh-keygen -r "${domain}" -f <(echo "${signature}")) | |
while IFS= read -r rr; do | |
array+=("${rr}") | |
done <<< "${dns_rr}" | |
done <<< "${signatures}" | |
IFS=$'\n' | |
echo "${array[*]}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment