This repository has been archived on 2020-03-24. You can view files and clone it, but cannot push or open issues or pull requests.
quay/util/security/ssh.py

13 lines
356 B
Python
Raw Normal View History

2019-11-12 16:09:47 +00:00
from __future__ import absolute_import
from Crypto.PublicKey import RSA
def generate_ssh_keypair():
"""
Generates a new 2048 bit RSA public key in OpenSSH format and private key in PEM format.
"""
key = RSA.generate(2048)
public_key = key.publickey().exportKey('OpenSSH')
private_key = key.exportKey('PEM')
return (public_key, private_key)