Skip to content

Instantly share code, notes, and snippets.

@samalba
Created February 13, 2013 03:12
Show Gist options
  • Save samalba/4941972 to your computer and use it in GitHub Desktop.
Save samalba/4941972 to your computer and use it in GitHub Desktop.
Generate SSH keys
import StringIO
from paramiko import DSSKey
def generate_ssh_key():
dss = DSSKey.generate()
out = StringIO.StringIO()
dss.write_private_key(out)
private_key = out.getvalue()
out.close()
public_key = 'ssh-dss {0}'.format(dss.get_base64())
return (private_key, public_key)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment