Can I connect to GHTorrent MySQL/Mongodb database through ssh?

久未见 提交于 2021-01-29 05:51:46

问题


I am trying to connect to GHTorrent database through ssh in python so I can deal with the data.

There is the example of how this ssh works in command lines and it works. http://ghtorrent.org/mysql.html

import pymysql
from sshtunnel import SSHTunnelForwarder

mypkey = paramiko.RSAKey.from_private_key_file("/Users/***/.ssh/id_rsa")
with SSHTunnelForwarder(
     ('web.ghtorrent.org', 3306), 
        ssh_username="ghtorrent",  
        ssh_pkey=mypkey, 
        ssh_private_key_password="*****",#my password for my pc
        remote_bind_address=('web.ghtorrent.org', 3306)) as server:  
    conn = pymysql.connect(host='127.0.0.1', 
                       port=server.local_bind_port,
                       user='ght', 
                       passwd='', 
                       db='ghtorrent')

From my code the ssh can't connect to the server. I am not really sure whether my connection information is correct.

Since it uses a website name rather than the IP address so I have no idea whether it works.

Thank you so much!


回答1:


Firstly, the GHTorrent SSH server is listening on port 22, you are trying to connect to 3306, which is incorrect.

Also, have you tried just specifying the SSH private key path directly? i.e. ssh_pkey="/Users/***/.ssh/id_rsa"

SSHTunnelForwarder(
 ('web.ghtorrent.org', 22), 
    ssh_username="ghtorrent",  
    ssh_pkey="/Users/***/.ssh/id_rsa", 
    ssh_private_key_password="*****",#my password for my pc
    remote_bind_address=('web.ghtorrent.org', 3306))


来源:https://stackoverflow.com/questions/55766606/can-i-connect-to-ghtorrent-mysql-mongodb-database-through-ssh

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!