1

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.

1 Answer 1

1

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')
Sign up to request clarification or add additional context in comments.

3 Comments

Thanks, I have tried those both : ssh -i C:\\id_dsa -L 3306:127.0.0.1:22 xxx.xxx.xxx.xxx and ssh -i 'C:\\id_dsa' -L 3306:127.0.0.1:22 xxx.xxx.xxx.xxx but i got the error code SyntaxError: invalid syntax. Note that it is normal that my file doesn't have any extension, that's the way it was give it to me.
Oh I didn't think you were on Windows, let me search the ssh command for that.
@PepperoniPizza I'm on windows too, how do i SSH , i have putty running and can connect to phpmyadmin from browser already

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.