def run(self): path = config.ssh.keydir key = os.path.join(path, "id_rsa") if not os.path.exists(path): print "Creating SSH key dir '%s' ..." % path os.makedirs(path) else: print "SSH key dir '%s' already exists." % path if not os.path.exists(key): print "Creating SSH key at '%s' ..." % key print " (This could take a while)" options = {"filename": key, "bits": 4096, "pass": None} ckeygen.generateRSAkey(options) else: print "SSH key '%s' already exists." % key
def makeTestKeys(): opts = ckeygen.GeneralOptions() opts['type'] = 'rsa' opts['bits'] = 1024 opts['pass'] = '' # no passphrases - ugh. # for pth in ('client_id_rsa', 'server_id_rsa'): if not os.path.exists(pth): opts['filename'] = pth ckeygen.generateRSAkey(opts) if not os.path.exists('known_hosts'): text = " ".join( ["localhost"] + open("server_id_rsa.pub" ).readline().split()[:2] ) with open('known_hosts', 'wb') as f: f.write(text) f.write('\n') if not os.path.exists('authorized_keys'): import shutil # add client pubkey to authorized_keys file shutil.copy('client_id_rsa.pub', 'authorized_keys')
def makeTestKeys(): opts = ckeygen.GeneralOptions() opts['type'] = 'rsa' opts['bits'] = 1024 opts['pass'] = '' # no passphrases - ugh. # for pth in ('client_id_rsa', 'server_id_rsa'): if not os.path.exists(pth): opts['filename'] = pth ckeygen.generateRSAkey(opts) if not os.path.exists('known_hosts'): text = " ".join(["localhost"] + open("server_id_rsa.pub").readline().split()[:2]) with open('known_hosts', 'wb') as f: f.write(text) f.write('\n') if not os.path.exists('authorized_keys'): import shutil # add client pubkey to authorized_keys file shutil.copy('client_id_rsa.pub', 'authorized_keys')