Unverified Commit 93f247c0 authored by 老广's avatar 老广 Committed by GitHub

Merge pull request #202 from jumpserver/dev

[Bugfix] 修复使用网关失败的bug
parents 5b631ad1 23a5574a
...@@ -129,17 +129,21 @@ class SSHConnection: ...@@ -129,17 +129,21 @@ class SSHConnection:
password=gateway.password, password=gateway.password,
pkey=gateway.private_key_obj, pkey=gateway.private_key_obj,
timeout=config['SSH_TIMEOUT']) timeout=config['SSH_TIMEOUT'])
except: except Exception as e:
logger.error("Connect gateway error")
logger.error(e, exc_info=True)
continue continue
try: try:
transport = ssh.get_transport() transport = ssh.get_transport()
transport.set_keep_alive(20) transport.set_keepalive(20)
sock = transport.open_channel( sock = transport.open_channel(
'direct-tcpip', (asset.ip, asset.port), ('127.0.0.1', 0) 'direct-tcpip', (asset.ip, asset.port), ('127.0.0.1', 0)
) )
break break
except: except Exception as e:
return None logger.error("Open gateway channel error")
logger.error(e, exc_info=True)
continue
return sock return sock
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment