def format_openssh_pubkey(key: PKey) -> str: """Format the given ``key`` to an OpenSSH public key line, used by :file:`authorized_keys`, :file:`id_rsa.pub`, etc. :param key: the key object to format :type key: :class:`paramiko.pkey.PKey` :return: a formatted openssh public key line :rtype: :class:`str` """ return '{} {} '.format(key.get_name(), key.get_base64())
def register(self, identity: Identity, public_key: PKey) -> None: with self._connect() as connection: cursor = connection.cursor() try: params = (self._get_key_params(public_key) + (public_key.get_base64(),) + self._get_identity_params(identity)) self._execute(cursor, ''' INSERT INTO geofront_public_key ( key_type, key_fingerprint, key_base64, team_type, identifier ) VALUES (?, ?, ?, ?, ?) ''', params) connection.commit() except self.integrity_error as e: raise DuplicatePublicKeyError(str(e)) finally: cursor.close()