Saturday, January 8, 2022

[SOLVED] SSH tunnle to mongodb using mongodb connection string

Issue

Thought it should be straight forward but I have a very hard time figuring out the following:

I got mongodb connection string: mongodb://user:[email protected]:27017/?authSource=admin

I want to be able to connect to mongo from localhost at port 1234 by doing: mongo localhost:1234 The solution is to create a tunnel, but nothing I do works for me.

I tried the following command:

ssh -L 1234:localhost:27017 user:[email protected] -p 27017

Please help me understand what I am doing wrong.


Solution

You need to have a unix user on 123.123.123.111

ssh -L 1234:localhost:27017 [email protected]

Then your local mongodb connection string is : mongodb://user:password@localhost:1234/?authSource=admin



Answered By - Philippe