Reputation: 901
I am trying to use MySQLdb but I didn't find anywhere how to make connection throught a SSH Tunel using a public key. Anybody can please guide me throught this ?
Thank you very much.
Upvotes: 1
Views: 1387
Reputation: 9112
As you said, you need first to create a tunnel, so in your shell do:
ssh -i ~/.ssh/keyfile.pem -L 3306:127.0.0.1:22 <hostIP>
and change your Python code to something like the following for connecting:
conn = MySQLdb.connect(host='127.0.0.1', port=3306, user='username', passwd='pass', db='DB')
Upvotes: 1