Skip to content

Instantly share code, notes, and snippets.

@typhonius
Last active December 17, 2015 15:09
Show Gist options
  • Save typhonius/5629619 to your computer and use it in GitHub Desktop.
Save typhonius/5629619 to your computer and use it in GitHub Desktop.
Quick snippet to convert public key signatures from an authorized_keys file into their ssh fingerprint
# Quick snippet to convert public key signatures from an authorized_keys file into their ssh fingerprint
# Usage: python fingerprint_conversion.py authorized_keys
import base64,hashlib,sys
line = sys.argv[1]
f = open(line, 'r')
for key in f:
key = str(key.strip().split()[1])
k = base64.b64decode(key + '=' * (-len(key) % 4))
fp_plain = hashlib.md5(k).hexdigest()
print ':'.join(a+b for a,b in zip(fp_plain[::2], fp_plain[1::2]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment