sshtunnel

cooolr 于 2022-08-12 发布
  1. 安装

    pip install sshtunnel

  2. 使用

from sshtunnel import SSHTunnelForwarder

server = SSHTunnelForwarder(
    ssh_address_or_host=("192.168.1.158", 22),
    ssh_username="root",
    ssh_password="123456",
    remote_bind_address=("127.0.0.1", 55212),
    #local_bind_address=('0.0.0.0', 55212)
)

server.start()

print(server.local_bind_port)

server.stop()