Enable ssh VPN tunnel to access phpmyadmin on google cloud


If you are looking to enable ssh VPN tunnel to access phpmyadmin on google cloud, here is a possible solution

This hint is especially good if you are trying to connect to your MySQL database server using phpMyAdmin.

It is assumed that you have already setup your Google Cloud server, installed Apache, MySQL and phpMyAdmin.

Opening up phpMyAdmin for access from any machine (global access) is not a safe thing to do. It is insecure and not advised. Of course, you may add your IP address to the phpMyAdmin.conf file. But again, adding your IP to the phpMyAdmin.conf everytime is not advisable either.

Browser screen when accessing phpmyadmin before creating the ssh tunnel
Result when accessing phpmyadmin before creating SSH tunnel

The best thing to do is to create a VPN tunnel connection to your server, using the following instructions.

When you access phpmyadmin before creating the tunnel, shows you an error message similar to the one on the left.

So, we open the Cloud SDK Shell.



Then we create the VPN tunnel using the following command.

gcloud compute ssh <NAME-OF-INSTANCE-FOR-THE-TUNNEL
--zone <ZONE-WHERE-YOUR-INSTANCE-IS-LOCATED--ssh-flag="-L" --ssh-flag="8888:localhost:80"

eg., gcloud compute ssh myCentos-1 
--zone us-central1-b --ssh-flag="-L" --ssh-flag="8888:localhost:80"

Note: You will be replacing the words in bold above with your relevant server name and zone name.
phpmyadmin login screen is shown when accessing phpmyadmin after creating the ssh tunnel
phpMyAdmin Login Screen shows after successful creation of ssh tunnel


After doing the above, open phpMyAdmin from your browser by typing the address
http://localhost:8888/phpmyadmin/

Voila, you get the login screen!


No comments:

Imagen 3: A New Era of AI Image Creation?

  Google has just unveiled Imagen 3, the latest iteration of their Gemini AI. They're making bold claims about enhanced image quality, ...

Most Popular

Copyrighted.com Registered & Protected DWYE-NHTO-NBNH-7FFM