From: Eric S. Raymond Date: Thu, 8 Jan 2004 05:47:07 +0000 (+0000) Subject: Hang fix from Josh Glover. X-Git-Tag: 1-2 X-Git-Url: http://thyrsus.com/gitweb/?a=commitdiff_plain;h=1c4df6ecf7e9ff0515d30b6b30730f65abb58292;p=ssh-installkeys.git Hang fix from Josh Glover. --- diff --git a/ssh-installkeys b/ssh-installkeys index 4052940..df83270 100755 --- a/ssh-installkeys +++ b/ssh-installkeys @@ -14,7 +14,7 @@ Options: Author: Eric S. Raymond """ -# $Id: ssh-installkeys,v 1.14 2003/12/04 01:26:59 esr Exp esr $ +# $Id: ssh-installkeys,v 1.15 2003/12/30 17:15:58 esr Exp esr $ import os, sys, getopt, string, getpass, tempfile @@ -63,7 +63,7 @@ A critical module was not found. Probably this OS does not support it. Currently pexpect is intended for UNIX operating systems (including OS-X).""" __version__ = '0.94' -__revision__ = '$Revision: 1.14 $' +__revision__ = '$Revision: 1.15 $' __all__ = ['ExceptionPexpect', 'EOF', 'TIMEOUT', 'spawn', '__version__', '__revision__'] @@ -575,14 +575,19 @@ class ssh_session: child = spawn(command) if self.verbose: sys.stderr.write("-> " + command + "\n") - seen = child.expect(['assword:', EOF]) - if seen == 0: - if not self.password: - self.password = getpass.getpass('Remote password: ') - child.sendline(self.password) - seen = child.expect(EOF) - if self.verbose: - sys.stderr.write("<- " + child.before + "\n") + while True: + seen=child.expect([EOF,'assword:','continue connecting (yes/no)?']) + if seen == 0: + break + elif seen == 1: + if not self.password: + self.password = getpass.getpass('Remote password: ') + child.sendline(self.password) + seen = child.expect(EOF) + elif seen == 2: + child.sendline("yes") + if self.verbose: + sys.stderr.write("<- " + child.before + "\n") return child.before def ssh(self, command): return self.__exec("ssh -l %s %s \"%s\""%(self.user,self.host,command))