[CSHARP-1613] connection to mongodb with ssh using c# driver Created: 27/Mar/16  Updated: 14/Jun/19  Resolved: 28/Mar/16

Status: Closed
Project: C# Driver
Component/s: Connectivity
Affects Version/s: 2.2.3
Fix Version/s: None

Type: Bug Priority: Blocker - P1
Reporter: avi inbar Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Windows application running in .net against mongodb env on aws hosted in linux


Issue Links:
Duplicate
duplicates CSHARP-768 Support SSH Tunnels for Connections t... Closed
Related
is related to CSHARP-1142 Expose Stream Factory configuration i... Closed

 Description   

how can we connect with ssh to mongodb server which located in aws and hosted in Linux server.
we are getting a timeout when trying to connect to the mongo client.
we are working in .net application using c# driver and trying to connect via ssh client.
the following is snippet from our code:
using (var client = new SshClient("<ip of aws machine>", 22, "mongodb user", "password"))

{ client.Connect(); var connectionString = "mongodb://root:passwordOfMongoDB@localhost:27017"; MongoClient MongoClient = new MongoClient(connectionString); IAsyncCursor<BsonDocument> lst11 = MongoClient.ListDatabases(); client.Disconnect(); }

 Comments   
Comment by Manikandan [ 11/Jun/19 ]

Hi Craig,

  Can you share us a sample on how to inject SSHStreamFactory in ClusterConfigurator? https://stackoverflow.com/questions/56560795/how-to-connect-ssh-net-in-mongodb-c-sharp?noredirect=1#comment99705277_56560795

 

 

Comment by Craig Wilson [ 28/Mar/16 ]

Hi Avi,

We currently don't have a way to connect to MongoDB over SSH. We do have a hook where we can add this capability. It is the ClusterConfigurator property of MongoClientSettings. You can create a custom SshStreamFactory and inject it in using ClusterConfigurator.

Craig

Generated at Wed Feb 07 21:40:09 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.