Created
June 9, 2013 19:56
-
-
Save t3rmin4t0r/5744974 to your computer and use it in GitHub Desktop.
RSA PEM simplified example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from Crypto.PublicKey import RSA | |
def genKey(bits=1024): | |
key = RSA.generate(2048) | |
f = open('rsa1024.pem','w') | |
f.write(key.exportKey('PEM')) | |
f.close() | |
return "rsa1024.pem" | |
pem = genKey(512) | |
key = RSA.importKey(open(pem,"r").read()) | |
pubkey = key.publickey() | |
# TO generate ssh keys from these | |
# $ ssh-keygen -y -f rsa1024.pem >> ~/.ssh/authorized_keys | |
# and to test it, do | |
# $ ssh -i rsa1024.pem localhost |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment