class SspkdPull(object): def __init__(self): self.cf = SspkdConfig() self.util = SspkdUtil() def _pull(self): if self.cf.server.enabled: with open(self.cf.server.database, "r") as f: return f.read() cmdline = [ 'ssh', '-o IdentityFile=%s' % self.cf.client.pushkey, '-o IdentitiesOnly=yes', self.cf.client.keyserver, 'fetch' ] ssh = subprocess.Popen(cmdline, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = ssh.communicate() return out def pull(self, install=False, verify=True): signed_keys = self._pull() if verify: sshkeys = self.util.verify_keys(signed_keys) if install: self.util.install_keys(sshkeys) else: sshkeys = signed_keys return sshkeys
class SspkdPush(object): def __init__(self): self.cf = SspkdConfig() self.util = SspkdUtil() def _push(self, server, sshkeys, relay=False): print "pushing updated ssh public keys to %s%s..." % (server, " (relay)" if relay else "") # FIXME: Assume server installpath == client installpath cmdline = ["ssh", "-o IdentityFile=%s" % self.cf.client.pushkey, "-o IdentitiesOnly=yes", server, "receive"] ssh = subprocess.Popen(cmdline, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = ssh.communicate(input=sshkeys) print out def push(self, sshkeys, sign=True, relay=False): if sign: sshkeys = self.util.sign_keys(sshkeys) if relay: servers = self.cf.server.pushto else: servers = [self.cf.client.keyserver] for server in servers: if server: self._push(server, sshkeys, relay=relay)
class SspkdReceive: def __init__(self): self.cf = SspkdConfig() self.util = SspkdUtil() def receive(self, signed_keys): sshkeys = self.util.verify_keys(signed_keys) if self.cf.server.enabled: f = open(self.cf.server.database, "w") f.write(signed_keys) f.close() SspkdPush().push(signed_keys, sign=False, relay=True) if self.cf.server.onlystore: return self.util.install_keys(sshkeys)
class SspkdPush(object): def __init__(self): self.cf = SspkdConfig() self.util = SspkdUtil() def _push(self, server, sshkeys, relay=False): print "pushing updated ssh public keys to %s%s..." % ( server, " (relay)" if relay else "") # FIXME: Assume server installpath == client installpath cmdline = [ 'ssh', '-o IdentityFile=%s' % self.cf.client.pushkey, '-o IdentitiesOnly=yes', server, 'receive' ] ssh = subprocess.Popen(cmdline, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = ssh.communicate(input=sshkeys) print out def push(self, sshkeys, sign=True, relay=False): if sign: sshkeys = self.util.sign_keys(sshkeys) if relay: servers = self.cf.server.pushto else: servers = [self.cf.client.keyserver] for server in servers: if server: self._push(server, sshkeys, relay=relay)
def __init__(self): self.cf = SspkdConfig() self.util = SspkdUtil()