I am trying to replicate:
ssh -i [KEY] -L [FROM_PORT]:localhost:[TO_PORT] ubuntu@[REMOTE_SERVER_IP] in python and decided to use
sshtunnel for it. The command given above works and I can connect to the remote Theia IDE, but I can’t figure out how I need to configure
SSHtunnelForwarder to achieve the same from within python. I am probably misunderstanding its documentation: https://github.com/pahaz/sshtunnel
# I replaced the remote-ip with `126.96.36.199`. # I replaced my ip with `9188.8.131.52`. with SSHTunnelForwarder( ssh_address_or_host="184.108.40.206", # ip of remote server ssh_username="ubuntu", # username of remote server ssh_bind_address= ("127.0.0.1", 9191), # where to listen locally remote_bind_address= ("127.0.0.1", 8181) # where to send info coming to 22 # ssh-port 22 (default port) # localhost:9191 -> 220.127.116.11:22 -> localhost:8181 # which is basically 918.104.22.168:9191 -> 22.214.171.124:22 -> 126.96.36.199:8181 ) as server: server.start()
But when I try to connect to
http://localhost:9191/ I receive unable to connect; so the tunneling is probably broken. I added plenty of comments to the code to make it easier to spot my misunderstanding.
Check the Answers