Created
September 21, 2016 19:30
-
-
Save colossus9/c160d6376d7b543b16fe02612fb4f763 to your computer and use it in GitHub Desktop.
Show table of fingerprints for all key ciphers allowed on server using config at /etc/ssh/sshd_config
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 | |
# | |
# Reference: http://superuser.com/questions/929566/sha256-ssh-fingerprint-given-by-the-client-but-only-md5-fingerprint-known-for-se | |
# | |
# standard sshd config path | |
SSHD_CONFIG=/etc/ssh/sshd_config | |
# helper functions | |
function tablize { | |
awk '{printf("| %-7s | %-7s | %-47s |\n", $1, $2, $3)}' | |
} | |
LINE="+---------+---------+-------------------------------------------------+" | |
# header | |
echo $LINE | |
echo "Cipher" "Algo" "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 | awk '{print $2}') | |
sha256=$(awk '{print $2}' $host_key | base64 -d | sha256sum -b | awk '{print $1}' | xxd -r -p | base64) | |
echo $cipher MD5 $md5 | tablize | |
echo $cipher SHA-256 $sha256 | tablize | |
echo $LINE | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment