Skip to content

Instantly share code, notes, and snippets.

@samuelsh
Last active August 29, 2015 14:27
Show Gist options
  • Save samuelsh/d545f34b0c461499c62f to your computer and use it in GitHub Desktop.
Save samuelsh/d545f34b0c461499c62f to your computer and use it in GitHub Desktop.
Method genetates id_rsa and id_rsa.pub on client
def RSA_keys_generator(complexity=2048):
"""
Method generates id_rsa and id_rsa.pub on client. Tested on CentOS 6.x clients
"""
import paramiko
k = paramiko.RSAKey.generate(complexity)
k.write_private_key_file(os.path.expanduser('~/.ssh/id_rsa'))
with open(os.path.expanduser('~/.ssh/id_rsa.pub'), "w") as f:
f.write("ssh-rsa " + k.get_base64())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment