def public_key_fingerprint(key): paramiko_key = ParamikoRSAKey(vals=(key.e, key.n)) fp = hexlify(paramiko_key.get_fingerprint()) openssh_fp = ":".join([a+b for a, b in zip(fp[::2], fp[1::2])]) return openssh_fp
def public_key_fingerprint(key): # paramiko can compute the OpenSSH-style fingerprint # Only fingerprints the public key paramiko_key = ParamikoRSAKey(vals=(key.e, key.n)) fp = hexlify(paramiko_key.get_fingerprint()) # OpenSSH puts a ":" character between every pair of hex-digits. # For whatever reason. Readability, I guess. openssh_fp = ":".join([a + b for a, b in zip(fp[::2], fp[1::2])]) return openssh_fp
def get_fingerprint_for_rsa_key_path(path): key = RSAKey(filename=path) fp = key.get_fingerprint().encode('hex') return add_colons_to_fingerprint(fp)