diff options
author | vakarisz <vakarisz@yahoo.com> | 2022-03-22 12:10:38 +0200 |
---|---|---|
committer | Mike Salvatore <mike.s.salvatore@gmail.com> | 2023-03-02 13:29:45 -0500 |
commit | 32a3d33ca1c2d385954304a7a87186f574c780cc (patch) | |
tree | 9f3b730ffa23e9c144c2afb04078fcae43d3bc4f | |
parent | 6379b018ac49b1e869f1248b1d6743d316b5a37b (diff) |
Add timeout for opening an SSH channel
-rw-r--r-- | paramiko/client.py | 5 | ||||
-rw-r--r-- | paramiko/transport.py | 4 |
2 files changed, 8 insertions, 1 deletions
diff --git a/paramiko/client.py b/paramiko/client.py index 5667d7e7..a9e4e233 100644 --- a/paramiko/client.py +++ b/paramiko/client.py @@ -233,6 +233,7 @@ class SSHClient(ClosingContextManager): gss_host=None, banner_timeout=None, auth_timeout=None, + channel_timeout=None, gss_trust_dns=True, passphrase=None, disabled_algorithms=None, @@ -311,6 +312,8 @@ class SSHClient(ClosingContextManager): for the SSH banner to be presented. :param float auth_timeout: an optional timeout (in seconds) to wait for an authentication response. + :param float channel_timeout: an optional timeout (in seconds) to wait + for a channel open response. :param dict disabled_algorithms: an optional dict passed directly to `.Transport` and its keyword argument of the same name. @@ -401,6 +404,8 @@ class SSHClient(ClosingContextManager): t.banner_timeout = banner_timeout if auth_timeout is not None: t.auth_timeout = auth_timeout + if channel_timeout is not None: + t.channel_timeout = channel_timeout if port == SSH_PORT: server_hostkey_name = hostname diff --git a/paramiko/transport.py b/paramiko/transport.py index 2b6acd6e..0c6c3ad1 100644 --- a/paramiko/transport.py +++ b/paramiko/transport.py @@ -516,6 +516,8 @@ class Transport(threading.Thread, ClosingContextManager): self.handshake_timeout = 15 # how long (seconds) to wait for the auth response. self.auth_timeout = 30 + # how long (seconds) to wait for opening a channel + self.channel_timeout = 60 * 60 self.disabled_algorithms = disabled_algorithms or {} self.server_sig_algs = server_sig_algs @@ -1015,7 +1017,7 @@ class Transport(threading.Thread, ClosingContextManager): """ if not self.active: raise SSHException("SSH session not active") - timeout = 3600 if timeout is None else timeout + timeout = self.channel_timeout if timeout is None else timeout self.lock.acquire() try: window_size = self._sanitize_window_size(window_size) |