diff options
-rw-r--r-- | paramiko/client.py | 1 | ||||
-rw-r--r-- | paramiko/transport.py | 5 |
2 files changed, 6 insertions, 0 deletions
diff --git a/paramiko/client.py b/paramiko/client.py index ebf21b08..18139416 100644 --- a/paramiko/client.py +++ b/paramiko/client.py @@ -336,6 +336,7 @@ class SSHClient (ClosingContextManager): if banner_timeout is not None: t.banner_timeout = banner_timeout t.start_client() + t.set_sshclient(self) ResourceManager.register(self, t) server_key = t.get_remote_server_key() diff --git a/paramiko/transport.py b/paramiko/transport.py index 1de6ff09..21565673 100644 --- a/paramiko/transport.py +++ b/paramiko/transport.py @@ -281,6 +281,7 @@ class Transport (threading.Thread, ClosingContextManager): arguments. """ self.active = False + self._sshclient = None if isinstance(sock, string_types): # convert "host:port" into (host, port) @@ -636,6 +637,9 @@ class Transport (threading.Thread, ClosingContextManager): Transport._modulus_pack = None return False + def set_sshclient(self, sshclient): + self._sshclient = sshclient + def close(self): """ Close this session, and any open channels that are tied to it. @@ -646,6 +650,7 @@ class Transport (threading.Thread, ClosingContextManager): for chan in list(self._channels.values()): chan._unlink() self.sock.close() + self._sshclient = None def get_remote_server_key(self): """ |