python 使用mysqldb模块通过SSHTunnelForwarder隧道连接mysql (1)出于安全考虑,数据库服务器只允许堡垒机通过ssh访问,这对日常的使用带来了麻烦。昨天的工作中,就遇到了这样的问题,MySQL数据库放在了服务器A上,只允许服务器B来访问,而我在机器C上,可以通过ssh连接服务器B。为了解决在机器C上连接mysql这个问题 如下图...
python try: with SSHTunnelForwarder( ('ssh.example.com', 22), ssh_username="user", ssh_password="password", remote_bind_address=('127.0.0.1', 3306) ) as server: print('Connected to SSH server and port forwarding active') except Exception as e: print(f'Error connecting to SSH server:...
Hello, I'm having this problem too. My code is taken from the example on the help page: sshtunnel.SSH_TIMEOUT=5.0sshtunnel.TUNNEL_TIMEOUT=5.0withsshtunnel.SSHTunnelForwarder(('ssh.pythonanywhere.com'),ssh_username='my_username',ssh_password='my_pa_password',remote_bind_address=('xxxx.mys...