def ensureKeyPair(): from os import chmod assertDirectory(authDirectory(),dirMode="700") if PY3: perm=eval("0o700") else: perm=eval("0700") if not path.exists(myPrivateKeyFile()) and not path.exists(myPublicKeyFile()): warning("No key pair in",authDirectory()," .... Creating") pubkey, privkey = keygen(2 ** 64) open(myPublicKeyFile(),"w").write(key_to_str(pubkey)) open(myPrivateKeyFile(),"w").write(key_to_str(privkey)) chmod(myPublicKeyFile(),perm) chmod(myPrivateKeyFile(),perm) if not path.exists(myAuthenticatedKeysFile()): f=open(myAuthenticatedKeysFile(),"w") f.close() chmod(myAuthenticatedKeysFile(),perm)
def myAuthenticatedKeysFile(): return path.join(authDirectory(), "myAuthenticatedKeys")
def myPublicKeyFile(): return path.join(authDirectory(), "publicKey")
def myPrivateKeyFile(): return path.join(authDirectory(), "privateKey")