0

I've just found a development box which I can SSH into and I then installed MongoDB onto it and am connecting with pymongo. However when I try and connect I get a time out issue. My issue is how to set the credentials when I connect via the string:

client = MongoClient("mongodb://99.99.99.99/db_name")

Where can I set-up the SSH credentials or is it simply not possible to use a mongo server in this way? I'd like to be able to use username:password to get in, I saw something on ssh tunneling here:

https://www.digitalocean.com/community/tutorials/how-to-securely-configure-a-production-mongodb-server
3
  • 1
    You would either need to open the firewall to allow access to the port that MongoDB is running on (27017 by default) OR you can use ssh port forwarding to tunnel access to the mongo port over ssh. Commented Jun 28, 2016 at 21:12
  • I was trying to find out about the tunnel access - how can I do this? Commented Jun 29, 2016 at 5:38
  • What is connection string format for connection via ssh tunnel? Commented Sep 22, 2017 at 11:08

2 Answers 2

5

maybe you can use ssh, see this answer: MongoDB Via ssh-port-forward

You can accomplish this with SSH Tunneling, setting up your remote MongoDB instance to run on one of your local ports. By default, MongoDB runs on 27017, so in the example below, I've chosen to map my remote MongoDB instance to my local 27018 port.

If on your trying to copy a database from SERVER1 to LOCALHOST, you could run this command on your LOCALHOST:

ssh -L27018:localhost:27017 SERVER1

Sign up to request clarification or add additional context in comments.

Comments

2

Please go through this link : http://www.mkyong.com/mongodb/mongodb-allow-remote-access/

it may be helpful.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.