vendredi 4 septembre 2015

Connecting to remote mongodb through ssh in pymongo

I'm trying to connect to a remote mongodb instance.

To access the database outside of pymongo, I normally do the following:

> ssh ec2-user@ec9-9-9-9-9-9-9.blah.compute.amazonaws.com
-$ mongo
-$ use some_database
-$ db.some_collection.findOne()
....

The authentication here is done via a private key (my_key.pem) stored locally on my laptop and works fine.

However, when I do the same thing in python, it times out:

>>> from pymongo import MongoClient
>>> c = MongoClient('ec2-user@ec9-9-9-9-9-9-9.blah.compute.amazonaws.com')
>>> c['some_database']['some_collection'].find_one()

There's some authentication options listed here: http://ift.tt/1hIhIoB but I don't understand them enough to know if they are relevant.

How can I connect?




Aucun commentaire:

Enregistrer un commentaire