Python 3 and SSH Tunnel

D. Xenakis gouzounakis at hotmail.com
Thu Aug 8 20:46:30 EDT 2013


> > HOWTO anyone?
> 
> >
> 
> > What im trying to succeed here is create one SSH tunnel, so that i can connect from a python script running on my pc, to a remote MySQL database running on my Host and id like to stick with Python 3.3 .
> 
> >
> 
> > I contacted my host and he informed me that this is the only way.
> 
> >
> 
> > I tried pycrypto + paramiko but from what i have noticed, paramiko is not Python 3.3 ready.
> 
> 
> 
> I'm not sure what exactly is going on here, but why not simply
> 
> establish a tunnel using ssh(1) and then invoke your Python script
> 
> separately? You simply point your script at a database on localhost,
> 
> after establishing a tunnel from local 3306 to remote localhost:3306.
> 
> No need to play with Python crypto.
> 
> 
> 
> Alternatively, can you use PostgreSQL instead? :)
> 
> 
> 
> ChrisA

Yes you are right.
I've played with putty to achieve this but to be honest i'd like something more efficient. Opening putty everytime and making all the connection settings etc, and then running the programm, is kinda messy. Id like this to be done in an automatic way from the program so that things roll easy.
I thought maybe i should find a way how to call and run a batch file from inside my python program or a powershell command, but i do not know even if that could work for the ssh tunneling.

any ideas?



More information about the Python-list mailing list