Could not establish session to SSH gateway

Viewed 1654

I don't know where the issue is but when i start the server the error pops up.I even tried to change the ip addresses for the ssh_address but doesn't seem to work.I read on another question that it might be causing because of running it on pycharm(in which the getpass doesn't responds and the code stops the execution right there).

from getpass4 import getpass
from sshtunnel import SSHTunnelForwarder

ssh_host = "192.168.56.101"
ssh_port = 22
ssh_user = "xyx123"
ssh_password = getpass("Enter the password")

REMOTE_HOST = "192.168.56.101"
REMOTE_PORT = 21

server = SSHTunnelForwarder(ssh_address=(ssh_host, ssh_port),
                            ssh_username=ssh_user,
                            ssh_password=ssh_password,
                            remote_bind_address=(REMOTE_HOST, REMOTE_PORT)
                            )

server.start()

print("Connect to remote server via local port: [%s]" % server.local_bind_port)
try:
    while True:
        pass
except KeyboardInterrupt:
    print("Exiting user request")
    server.stop()

Terminal Errors:

enter image description here

In short this code should get the the local_bind_port by which i can access it further on command prompt.

0 Answers
Related