Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

executable file 43 lines (33 sloc) 1.02 kB
#!/usr/bin/env python
import pexpect
import sys
import shutil
import os
logfile = sys.stdout
print "try ssh"
try:
cmd="ssh-keygen -f %s" % (sys.argv[1])
child = pexpect.spawn (cmd, timeout=30, maxread=20000, logfile=logfile)
child.expect (':')
# print child.before
child.sendline ('')
child.expect (':')
# print child.before
child.sendline ('')
rc = child.expect(pexpect.EOF)
# print child.before
cmd = "cp %s.pub %s/.ssh/authorized_keys" % (sys.argv[1], os.environ['HOME'])
print cmd
child = pexpect.spawn (cmd, timeout=10, maxread=20000, logfile=logfile)
rc = child.expect(pexpect.EOF)
# print child.before
print "setting up ssh knowhosts"
cmd = "ssh -i %s localhost hostname" % (sys.argv[1])
child = pexpect.spawn (cmd, timeout=10, maxread=20000, logfile=logfile)
child.expect ('(yes/no)?')
# print child.before
child.sendline ('yes')
rc = child.expect(pexpect.EOF)
# print child.before
except Exception, ex:
print ex
Jump to Line
Something went wrong with that request. Please try again.