This guide will show you how to make a secure remote connection to your MySQL database.
Generating a key pair
In our example we will use puttygen to generate our keys. You can download putty here - https://www.putty.org/
Start PuTTYgen, and choose a type and Click the Generate button.
PuTTYgen will then ask you to wiggle your mouse around for a while to help it generate the key.
Once the green bar is filled PuTTYgen will create your keypair and you will see something like this:
You can add the name of the key in the comment key to something memorable and also add a passphrase in in the passphrase field.
Click the Save private key button and save your private key with the .ppk extension.
Make a note of or save the public key as we are going to need this later.
Adding the public key to your cPanel account
Login to cPanel and select SSH Access:
Click the Manage SSH Keys button.
Click the Import Key button to get the Import SSH Key screen.
Now add the name and keyphrase, aswell as paste you public key into the relevant fields and then click import.
The next step is to authorise your public key. From the ssh access page click 'manage' on the key you just imported
And then Authorize
Configuring the SSH tunnel in PUTTY
Open Putty
Enter the hostname or IP address of your cpanel account in the Host Name (or IP address) field.
Port should be set to port 22
In the left-hand menu, go to Connection -> SSH -> Tunnels.
In the Source port field, enter 3306.
In the Destination field, enter 127.0.0.1:3306. See the final configuration below:
Click Open to start the SSH session.
Once the connection has been made you should be able to connect to the database using a client such as MySQL Workbench or via a terminal.