15 lines
413 B
Python
15 lines
413 B
Python
from sshtunnel import SSHTunnelForwarder
|
|
import os
|
|
|
|
hostname = "192.168.88.3"
|
|
response = os.system("ping -c 1 " + hostname)
|
|
if response == 0:
|
|
ssh_tunnel = SSHTunnelForwarder(
|
|
'192.168.88.3',
|
|
ssh_username="orangepi",
|
|
ssh_password="cbvgcjy0",
|
|
remote_bind_address=('192.168.88.3', 22)
|
|
)
|
|
|
|
ssh_tunnel.start()
|
|
print(ssh_tunnel.local_bind_port) # show assigned local port |