Port Forwarding and Tunneling Using SSH
You can forward a remote port to a local port using SSH. To do so, try you can use the command below:
ssh -L local_bind_port:remote_connect_address:remote_connect_port username@remote_host
For example,
ssh -L 8080:google.com:80 username@server
will forward google.com to localhost:8080. This means when you open http://localhost:8080/ you will see google.com . The remote machine will connect google.com and this connection will be forwarded to your local computer in tunnel. This is really a great feature when you want to connect to a web site in your Intranet.
When you want to have a secure mysql connection, simply forwarding the remote mysql port to your local port using ssh will satisfy you.
ssh -L 3306:127.0.0.1:3306 username@server
will tunnel the remote mysql server to your machine. You should connect to the mysql server using host for localhost.
Good luck!!
