Skip to content

Instantly share code, notes, and snippets.

@dcmbrown
Last active November 13, 2023 18:04
Show Gist options
  • Save dcmbrown/64ff078fa09557e244371ae13a2ca303 to your computer and use it in GitHub Desktop.
Save dcmbrown/64ff078fa09557e244371ae13a2ca303 to your computer and use it in GitHub Desktop.
fingerprint ssh keys - something which happens all too regularly

Get your ssh key finger print

This function is useful when you need to know the fingerprint of your ssh keys because you have too many keys across too many systems or you're verifying your key use against a particular system/service.

Add this to your .bashrc/.bash_profile/.profile or whereever you keep your shell functions. Works in bash, have not verified use in zsh, csk, ksh, fish, etc.

# fingerprint an ssh key
function fingerprint(){
    if [ $# -eq 0 ]; then
            echo "usage: fingerprint [md5|sha256] <id_rsa.pub path>"
            return 1
    # default to md5
    elif [ $# -eq 1 ]; then
            ssh-keygen -E md5 -lf "${1}"
    # else run what is specified
    elif [ $# -eq 2 ]; then
            ssh-keygen -E "${1}" -lf "${2}"
    fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment