0

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!

eyllanesc
  • 235,170
  • 19
  • 170
  • 241

1 Answers1

0

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))
eddiecjc
  • 222
  • 2
  • 5