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

from __future__ import absolute_import
2015-03-16 17:37:27 +00:00
from Crypto.PublicKey import RSA
2015-03-18 21:32:59 +00:00
def generate_ssh_keypair():
2015-03-16 17:37:27 +00:00
"""
2015-03-18 21:32:59 +00:00
Generates a new 2048 bit RSA public key in OpenSSH format and private key in PEM format.
2015-03-16 17:37:27 +00:00
"""
key = RSA.generate(2048)
public_key = key.publickey().exportKey('OpenSSH')
2015-03-18 21:32:59 +00:00
private_key = key.exportKey('PEM')
return (public_key, private_key)