我可以通过 ssh 连接到 GHTorrent MySQL/Mongodb 数据库吗? [英] Can I connect to GHTorrent MySQL/Mongodb database through ssh?

查看:27
本文介绍了我可以通过 ssh 连接到 GHTorrent MySQL/Mongodb 数据库吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

有一个例子说明了这个 ssh 在命令行中是如何工作的,它是如何工作的.http://ghtorrent.org/mysql.html

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')

根据我的代码,ssh 无法连接到服务器.我不确定我的连接信息是否正确.

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

因为它使用的是网站名称而不是 IP 地址,所以我不知道它是否有效.

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

非常感谢!

推荐答案

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

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

另外,您是否尝试过直接指定 SSH 私钥路径?即 ssh_pkey="/Users/***/.ssh/id_rsa"

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))

这篇关于我可以通过 ssh 连接到 GHTorrent MySQL/Mongodb 数据库吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆