Mongo db connection string with ssh username and password

Hi guys,

I’m trying to connect to mongo from app, using mongoose. I’m connected to the server using openVPN and have server username, password and also SSH username and password, address and port. I can’t connect to the database. What type of connection string should I use ?

Ideally the port should be available on the network so only VPN connection would be required.

If you still need to use ssh as well then configure a SSH port forwarding and use that. If a replicaset is in use then set the port forward to the primary and specify directConnection=true on the connection string.

As you’re using the node driver if SSH allows dynamic proxy the proxy options can be specified in the connection string and `directConnection will not be required:
https://mongodb.github.io/node-mongodb-native/6.3/interfaces/MongoClientOptions.html#proxyHost