我可以通过ssh连接到GHTorrent MySQL / Mongodb数据库吗?



我正在尝试通过python中的ssh连接到GHTorrent数据库,以便我可以处理数据。

有一个示例说明此 ssh 如何在命令行中工作,并且它的工作原理。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')

从我的代码中,ssh 无法连接到服务器。我不太确定我的连接信息是否正确。

由于它使用网站名称而不是IP地址,因此我不知道它是否有效。

非常感谢!

首先,GHTorrent SSH 服务器正在侦听端口 22,您正在尝试连接到 3306,这是不正确的。

另外,您是否尝试过直接指定SSH私钥路径?即 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))

最新更新