Commit c210e80d authored by Sébastien Luttringer's avatar Sébastien Luttringer
Browse files

Fix traceback around ssh connection with agent

Ssh connection with agent fail when agent is not able to auth and claims "No Session"
instead of using provided password.

[1] http://stackoverflow.com/questions/6832248/paramiko-no-existing-session-exception
[2] https://github.com/paramiko/paramiko/issues/126
parent 09319f9c
Loading
Loading
Loading
Loading
+22 −17
Original line number Diff line number Diff line
@@ -183,12 +183,14 @@ class PipeFile(object):
            "ssh://(([^:]+)(:([^@]+))?@)?([^/:]+)(:(\d+))?(/.*)?", path).group(2, 4, 5, 7, 8)
        if port is None: port = 22
        if path is None: path = "/"
        try:
            # open ssh connection
            # we need to keep it inside the object unless it was cutted
            self._ssh = paramiko.SSHClient()
            self._ssh.load_system_host_keys()
            self._ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
        self._ssh.connect(host, port=port, username=login, password=passwd,
            # Here there is a bug arround conect with allow_agent if agent is not able to open with a key
            self._ssh.connect(host, port=port, username=login, password=passwd, allow_agent=True,
                              look_for_keys=True, timeout=self.timeout)
            # swith in sftp mode
            sftp = self._ssh.open_sftp()
@@ -200,6 +202,9 @@ class PipeFile(object):
            self.fo = sftp.open(path, self.mode)
            # this is needed to have correct file transfert speed
            self.fo.set_pipelined(True)
        except Exception as e:
            # FIXME: unable to open file
            raise IOError(e)

    def close(self):
        if self.progressbar: