php – Connecting to mysql over ssh tunnel on Windows

Question:

There is a server with MySQL , and you need to connect to it on a client created in php devel studio . I want to make a connection via an ssh tunnel, on Unix it can be done like this:

shell_exec("ssh -f -L 127.0.0.1:3307:127.0.0.1:3306 user@remote.rjmetrics.com sleep 60 >> logfile");  
$db = mysqli_connect("127.0.0.1", "sqluser", "sqlpassword", "rjmadmin", 3307);  

But the client will work on Windows, how can you do the same without using additional programs? Or maybe there is some kind of component in devel studio for this purpose?

Answer:

putty can be used from the windows command line, something like this:

shell_exec("putty.exe -ssh user@remote.rjmetrics.com -L 127.0.0.1:3307:127.0.0.1:3306");
Scroll to Top