Skip to content

Instantly share code, notes, and snippets.

@igorhrq
Created December 30, 2020 03:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save igorhrq/f03bfb3122b5aa4057a6eb7e88d8f0c7 to your computer and use it in GitHub Desktop.
Save igorhrq/f03bfb3122b5aa4057a6eb7e88d8f0c7 to your computer and use it in GitHub Desktop.
# Author: Igor Andrade
# generate a public and private key at /root dir
import os
from Crypto.PublicKey import RSA
key = RSA.generate(4096)
with open("/root/priv8.key", 'wb') as arquivo:
os.chmod("/root/priv8.key", 0o600)
arquivo.write(key.exportKey('PEM'))
pubkey = key.publickey()
with open("/root/public.pub", 'wb') as arquivo:
arquivo.write(pubkey.exportKey('OpenSSH'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment