python sshtunnel ssh代理

时间:2017-05-27 16:42:34

标签: python linux proxy socks

我想从我的ssh linux服务器创建proxy / socks服务。我已经使用sshtunnel为mysql创建了端口转发器,示例代码:

from sshtunnel import SSHTunnelForwarder
from sqlalchemy import create_engine
from sqlalchemy.engine.url import URL

with SSHTunnelForwarder(('mydomain.com', 22), ssh_username='root', ssh_password='password', local_bind_address=('127.0.0.1', 3306), remote_bind_address=('127.0.0.1', 3306)) as server:
    myDB = URL(drivername='mysql+pymysql', host='127.0.0.1', database='test_db', username='root', password='THawr_tapH3f', port=3306)

    engine = create_engine(name_or_url=myDB)
    connection = engine.connect()    
    connection.close() 

我想用python在proxy / socks4 / 5服务中转换我的ssh linux机器;我怎样才能做到这一点?

0 个答案:

没有答案