Reputation: 113
I am going to connect to mongodB in the server from clinet1. I created an SSHTunnelForwarder in the client to transfer my traffic in the port 27017 to the server and connect the server mongoDB database.
server = SSHTunnelForwarder(
(MONGO_HOST),
ssh_username=MONGO_USER,
ssh_password=MONGO_PASS,
remote_bind_address=('127.0.0.1', 27017),
)
server.start()
client = MongoClient('127.0.0.1', server.local_bind_port)
but I received this error in server.start() :
sshtunnel.BaseSSHTunnelForwarderError: Could not establish session to SSH gateway python mongodb site:stackoverflow.com
Is there any solution to deal with this issue?
Upvotes: 1
Views: 1301
Reputation: 624
Did you declare "MONGO_HOST" as a tuple? like below
MONGO_HOST = ('host', 22)
I looked for it SSHTunnelForwarder
I think this lib is connected by ssh method.
but I think you put not ssh account
and password
in ssh_username
and ssh_password
Upvotes: 1