util.ssh: generate ssh key method
This commit is contained in:
parent
b35f6ed25c
commit
c9d955e432
1 changed files with 11 additions and 0 deletions
11
util/ssh.py
Normal file
11
util/ssh.py
Normal file
|
@ -0,0 +1,11 @@
|
|||
from Crypto.PublicKey import RSA
|
||||
|
||||
def generate_ssh_key():
|
||||
"""
|
||||
Generates a new 2048 bit RSA private key in PEM format and public key in OpenSSH format.
|
||||
"""
|
||||
key = RSA.generate(2048)
|
||||
private_pem = key.exportKey('PEM')
|
||||
public_key = key.publicKey().exportKey('OpenSSH')
|
||||
return (private_pem, public_key)
|
||||
|
Reference in a new issue