@@ -557,7 +557,7 @@ def FindSSHConfig(identity, config):
557557    return  False 
558558
559559
560- def  GetSessionTty ():
560+ def  GetSessionTty (mode   =   "r" ):
561561    """Returns a file descriptor for the session TTY, or None. 
562562
563563    In *nix systems, each process is tied to one session. Each 
@@ -591,8 +591,8 @@ def GetSessionTty():
591591    None otherwise. 
592592    """ 
593593    try :
594-         fd  =  open ("/dev/tty" , "r" )
595-         fcntl .ioctl (fd , termios .TIOCGPGRP , "  " )
594+         fd  =  open ("/dev/tty" , mode )
595+         fcntl .ioctl (fd , termios .TIOCGPGRP , b "  "
596596    except  IOError :
597597        return  None 
598598    return  fd 
@@ -673,16 +673,17 @@ class AgentManager(object):
673673        Args: 
674674          keys: iterable of strings, each string a path to a key to load. 
675675        """ 
676+         console_in  =  GetSessionTty ("r" )
677+         console_out  =  GetSessionTty ("w" )
676678        keys  =  " " .join (keys )
677679        options  =  self .config .Get ("SSH_ADD_OPTIONS" ).get (
678680            self .identity , self .config .Get ("SSH_ADD_DEFAULT_OPTIONS" )
679681        )
680-         console  =  GetSessionTty ()
681682        self .RunShellCommandInAgent (
682683            self .agent_file ,
683684            "ssh-add {0} {1}" .format (options , keys ),
684-             stdout = console ,
685-             stdin = console ,
685+             stdout = console_out ,
686+             stdin = console_in ,
686687        )
687688
688689    def  GetLoadedKeys (self ):
0 commit comments