BASH
50
ssh fingerprint server bbd sh
Guest on 17th June 2022 01:18:38 AM
#!/bin/bash
# Original from:
# https://superuser.com/questions/929566/sha256-ssh-fingerprint-given-by-the-client-but-only-md5-fingerprint-known-for-sex
#
# Modified by Edmund Laugasson
#
# Run current script:
# source script.sh
# Set US English as default language for current script
LC_ALL=C
# standard sshd config path
SSHD_CONFIG=/etc/ssh/sshd_config
# helper functions
function tablize {
awk '{printf("| %-7s | %-66s |\n", $1, $3)}'
}
LINE="+---------+--------------------------------------------------------------------+"
# header
echo $LINE
echo "Cipher" "Fingerprint" "Fingerprint" | tablize
echo $LINE
# fingerprints
for host_key in $(awk '/^HostKey/ {sub(/^HostKey\s+/,"");print $0".pub"};' $SSHD_CONFIG); do
cipher=$(echo $host_key | sed -r 's/^.*ssh_host_([^_]+)_key\.pub$/\1/'| tr '[a-z]' '[A-Z]')
if [[ -f "$host_key" ]]; then
md5=$(ssh-keygen -l -f $host_key -E md5 | awk '{print $2}')
sha256=$(ssh-keygen -l -f $host_key | awk '{print $2}')
bbd=$(ssh-keygen -B -f $host_key | awk '{print $2}')
echo $cipher MD5 $md5 | tablize
echo $cipher SHA256 $sha256 | tablize
echo $cipher BBD $bbd | tablize
echo $LINE
fi
done
# BBD - easy to memorize bubblebabble digest
# man ssh-keygen and search bubblebabble