Creating an SSH tunnel for Remote MySQL Imprimer

  • 0

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.

1667632683499-sshtunnel1.PNG

 

PuTTYgen will then ask you to wiggle your mouse around for a while to help it generate the key.

1667632811437-sshtunnel2.PNG

 

Once the green bar is filled PuTTYgen will create your keypair and you will see something like this:

1667632904526-sshtunnell3.PNG

 

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:

1667633012582-sshtunnel4.PNG

 

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.

 

1667633083792-sshtunnel5.PNG

 

The next step is to authorise your public key. From the ssh access page click 'manage' on the key you just imported

 

1667633162560-sshtunnel6.PNG

 

And then Authorize

1667633238161-sshtunnel7.PNG

 

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

1667633317848-sshtunnel8.PNG

 

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:

1667633428810-sshtunnel9.PNG

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.


Cette réponse était-elle pertinente?

« Retour