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 ghtorrent@dutihr.st.ewi.tudelft.nl

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
babeyh
  • 659
  • 2
  • 7
  • 19
  • Does this answer your question? [How to connect remote mongodb with pymongo](https://stackoverflow.com/questions/42718547/how-to-connect-remote-mongodb-with-pymongo) – paltaa Oct 30 '19 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. – babeyh Oct 30 '19 at 21:36
  • I showed this question, too https://stackoverflow.com/questions/55766606/can-i-connect-to-ghtorrent-mysql-mongodb-database-through-ssh – babeyh Oct 30 '19 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. – babeyh Oct 30 '19 at 21:38
  • and what is the error ? – paltaa Oct 30 '19 at 21:38
  • 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 – babeyh Oct 30 '19 at 21:39

0 Answers0