0

I want to connect MongoDB server with python.

I have connected it on the terminal of MacOS and I run some MongoDB queries. (as described this link http://ghtorrent.org/raw.html)

sshtunnel: ssh -L 27017:dutihr.st.ewi.tudelft.nl:27017 [email protected]

connect to mongo: mongo -u ghtorrentro -p ghtorrentro github

what are the parameters of the above "ssh" and "mongo" commands?

How to connect remote mongodb with pymongo and Can I connect to GHTorrent MySQL/Mongodb database through ssh?

I see these question, I tried to write my code according to these answers but it's not working.

import pymongo
import sshtunnel
from sshtunnel import SSHTunnelForwarder
import paramiko
mypkey = paramiko.RSAKey.from_private_key_file("/Users/aaa/.ssh/id_rsa","xxx") #username(aaa) and password(xxx)
server = SSHTunnelForwarder(
     ('dutihr.st.ewi.tudelft.nl', 22), 
        ssh_username="",  
        ssh_pkey=mypkey, 
        ssh_private_key_password="xxx", #my password for key
        remote_bind_address=('0.0.0.0',27017))
server.start()

how can I find the right parameters of these codes? how can I connect this MongoDB server? It give this error;

2019-10-31 00:11:51,304| ERROR | Secsh channel 49 open FAILED: open failed: Administratively prohibited 
2019-10-31 00:11:51,305| ERROR | Could not establish connection from ('127.0.0.1', 51634) to remote side of the tunnel
6
  • Does this answer your question? How to connect remote mongodb with pymongo Commented Oct 30, 2019 at 21:32
  • I showed the question but it is not worked for me. I did not connect to DB if I success it, I will try this answer of the question. Commented Oct 30, 2019 at 21:36
  • I showed this question, too stackoverflow.com/questions/55766606/… Commented Oct 30, 2019 at 21:37
  • First of all, I want to figure out the parameters of ssh and mongo commands. Because I connect the DB with the terminal. Commented Oct 30, 2019 at 21:38
  • and what is the error ? Commented Oct 30, 2019 at 21:38

0

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.