def save(self):
if self.have_config:
self.write(open(KeyConfig.configfile(), "w"))
- def readremote(self, session):
+ def remember(self, session):
authorized = session.ssh("cat ~/.ssh/authorized_keys")
keydict = {}
for line in authorized.split("\n"):
self.add_section(session.host)
for (keyid, types) in keydict.items():
self.set(session.host, keyid, ",".join(types))
+ def forget(self, host):
+ self.remove_section(host)
def die(msg):
"Die quietly."
if delete:
os.system('ssh -l %s %s "rm -fr .ssh"' % (login, host))
- config.remove_section(host)
+ config.forget(host)
print "Keys for %s on %s have been deleted." % (login, host)
raise SystemExit, 0
# OK, install keys remotely if they don't exist
if session.exists("~/.ssh/authorized_keys"):
print "authorized_keys already exists on", host
- config.readremote(session)
+ config.remember(session)
elif not check:
print "Copying your public keys to", host
session.scp(keyfile, "~/.ssh/authorized_keys")
- config.readremote(session)
+ config.remember(session)
except SystemExit:
pass
except RuntimeError: