我在 python 上使用来自 sshtunnel 模块的 SSHTunnelForwarder。
给定下一个代码:
server = SSHTunnelForwarder(
(sshServer, sshPort),
ssh_username=sshUsername,
ssh_password=sshPassword,
remote_bind_address=(imapServer, imapPort),
local_bind_address=('127.0.0.1', localPort)
)
print('STARTING')
server.start()
print(server.is_active)
有时需要很长时间,也许几分钟,然后我得到错误:
2019-04-22 22:25:54,365| ERROR | Could not connect to gateway ip..... : 110
Traceback (most recent call last):
File "PYTHON_TUNNEL.py", line 24, in <module>
server.start()
File "/home/mike/.local/lib/python2.7/site-packages/sshtunnel.py", line 1295, in start
reason='Could not establish session to SSH gateway')
File "/home/mike/.local/lib/python2.7/site-packages/sshtunnel.py", line 1101, in _raise
raise exception(reason)
sshtunnel.BaseSSHTunnelForwarderError: Could not establish session to SSH gateway
Ubuntu 18.04,蟒蛇 2.7
是否可以设置隧道建立超时?
米琪卡哇伊
相关分类