Guide to create a tunneled SSH connection in MySQL for Excel
By Javier Rivera-Oracle on Feb 04, 2014
This section describes how to get a secure connection to a remote MySQL server with SSH.
If you have any questions regarding the following post, please share them with us at: MySQL For Excel Forum
Creating a SSH tunnel to MySQL using PuTTY
This is the second part of the complete Guide to install and configure SSH in a MySQL server on Windows tutorial, we will cover how to create the tunnel from the client using putty. For the first part of this tutorial, please refer to How to: Guide to install and configure SSH in a MySQL server on Windows.
Tunneling is a technique that consist on creating a connection between your PC and a server and make it appear as if the remote MySQL database you’re accessing through the tunnel is locally running from your machine. We will use Putty which is a free tool that will help us to accomplish our goals in this tutorial. It can be downloaded from here.
1. Create a new session.
Open PuTTY and fill out the "Host Name" box with your server and the SSH port to connect to it. Don’t forget to give a name to the session and save it:
2. Port Forwarding
With the session that you just created selected, click the "Tunnels" option under the "SSH" tab to the left. Type the source port you want to reference locally and Destination values make sure to also check the boxes as the following image shows before clicking the “Add” button:
Source port - this is the local port the tunnel will connect to, this box should be filled in with an unused port on your system. For this example we used ‘3356’ but it could be other number as well.
Destination - this is the address and port of your actual remote MySQL server.
Here is how the screen will look like once you had clicked the Add button:
3. Open the connection
Once again, press the "Save" button to save the changes to the current session. Next press "Open" to start your session:
The last thing to do is login in the remote server with the credentials you created for the SSH server on the second part of the first tutorial:
If you succeeded the window may look like:
Now that the tunnel is created, you can create a connection to make queries and updates to your remote database, but pointing to your local port like if you had the db running locally:
Wrapping up what we have seen here today, we first installed Putty on our local machine, then configure the connection information, create the forwarding port, save all settings and open the connection. In this posts we have learn how to create a SSH tunnel to reference a remote MySQL database as if it were running locally (on Windows).
For more information related to SSH please visit the following sources in below:
Amazon - http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/putty.html
Rackspace - http://www.rackspace.com/knowledge_center/article/rackspace-cloud-essentials-3-going-from-windows-to-linux-using-putty
Azure - http://www.windowsazure.com/en-us/documentation/articles/linux-use-ssh-key/