Python utilities to simplify connection with MongoDB through SSH tunnel. Note: uri parameter is assumed as local, after ssh.
The source code is currently hosted on GitHub at: https://github.com/pualien/pymongo-ssh
Binary installers for the latest released version are available at the Python package index
pip install pymongo-ssh
from pymongo_ssh import MongoSession
session = MongoSession('db.example.com')
db = session.connection['db-name']
session.stop()
# session.start()
session = MongoSession(
host='db.example.com',
uri='mongodb://user:[email protected]/?authSource=admin&authMechanism=SCRAM-SHA-256'
)
...
session.stop()
session = MongoSession(
host='db.example.com',
user='myuser',
password='mypassword',
)
...
session.stop()
session = MongoSession(
host='db.example.com',
port='21',
user='myuser',
key='/home/myplace/.ssh/id_rsa2',
to_port='37017',
to_host='0.0.0.0'
)
...
session.stop()