Sunday, November 27, 2016

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.

--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

Voila, you get the login screen!

No comments:

Locking Unlocking Aadhar Biometrics, Lock Unlock

Recently, there was a news item, which claimed that we can lock and unlock our Aadhar biometric details from being requested for biometric ... Registered & Protected DWYE-NHTO-NBNH-7FFM