From c9d955e43278bf00351855021c579af586f95b1d Mon Sep 17 00:00:00 2001 From: Jimmy Zelinskie Date: Mon, 16 Mar 2015 13:37:27 -0400 Subject: [PATCH] util.ssh: generate ssh key method --- util/ssh.py | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 util/ssh.py diff --git a/util/ssh.py b/util/ssh.py new file mode 100644 index 000000000..eaa1b9c66 --- /dev/null +++ b/util/ssh.py @@ -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) +