def get_ssh_key_fingerprint(ssh_key):
 parts = ssh_key.strip().split()
 if (len(parts) == 0):
  return None
 key_type = parts[0]
 key = base64.b64decode(parts[1].encode('ascii'))
 fp_plain = hashlib.md5(key).hexdigest()
 key_fp = ':'.join(((a + b) for (a, b) in zip(fp_plain[::2], fp_plain[1::2]))).upper()
 if (len(parts) < 3):
  return ('%s (%s)' % (key_fp, key_type))
 else:
  user_host = parts[2]
  return ('%s %s (%s)' % (key_fp, user_host, key_type))

def get_ssh_key_fingerprint ( ssh_key ) : parts = ssh_key . strip ( ) . split ( ) if ( len ( parts ) == 0 ) : return None key_type = parts [ 0 ] key = base64 . b64decode ( parts [ 1 ] . encode ( 'ascii' ) ) fp_plain = hashlib . md5 ( key ) . hexdigest ( ) key_fp = ':' . join ( ( ( a + b ) for ( a , b ) in zip ( fp_plain [ : : 2 ] , fp_plain [ 1 : : 2 ] ) ) ) . upper ( ) if ( len ( parts ) < 3 ) : return ( '%s (%s)' % ( key_fp , key_type ) ) else : user_host = parts [ 2 ] return ( '%s %s (%s)' % ( key_fp , user_host , key_type ) )
return the public key fingerprint of a given public ssh key in format "fb:0c:ac:0a:07:94:5b:ce:75:6e:63:32:13:ad:ad:d7 [user@host] " .