def exists(self, fn):
"Retrieve file permissions of specified remote file."
seen = self.ssh("/bin/ls -ld %s" % fn)
+ if not seen.strip():
+ sys.stderr.write("Remote ls returned empty string, bailing out.\n")
+ raise SystemExit, 2
if self.verbose:
sys.stderr.write("Existence check on %s gave %s\n" % (fn, repr(seen)))
if seen.find("No such file") > -1:
if delete:
os.system('ssh -l %s %s "rm -fr .ssh"' % (login, host))
config.forget(host)
- print "Keys for %s on %s have been deleted." % (login, host)
+ print "Keys for %s@%s have been deleted." % (login, host)
raise SystemExit, 0
# Update or check
if session.exists("~/.ssh/authorized_keys"):
print "authorized_keys already exists on", host
config.remember(session)
- elif not check:
+ elif check:
+ print "Check of %s@%s is complete." % (login, host)
+ else:
print "Copying your public keys to", host
session.scp(keyfile, "~/.ssh/authorized_keys")
config.remember(session)
+ print "Keys for %s@%s have been installed." % (login, host)
except SystemExit:
pass
except RuntimeError:
sys.exit(-1)
# It's all over now...
os.remove(keyfile)
- if check:
- print "Check is complete."
- else:
- print "Keys for %s on %s have been installed." % (login, host)
config.save()
# End
</refsect1>
<refsect1><title>Bugs</title>
-<para>There are persistent reports that seem to indicate that this
-script occasionally chokes on a bogus, empty return from ls -ld, but
-I don't know what can cause ls -ld to do that and am reluctant to
-paper over the problem rather than actually fixing it.</para>
+<para>This program relies on ptys to work correctly in combination with exec,
+but some implementations (notably under FreeBSD) don't. Suspect this if
+you see termination with the message "Remote ls returned empty string,
+bailing out"</para>
<para>If you encounter this or any other bug, the first thing to do is
-run with -v and see if that clarifies matters. If not, send me a
+run with -v and see if that clarifies matters. If not, send the maintainer a
session transcript.</para>
</refsect1>