One Page Zen

Web Design. Simplified.

  • Tutorials
    • Google Cloud
    • Amazon Cloud
    • Microsoft Cloud
  • Start
  • Resources

How to Access phpMyAdmin via SSH Tunnel (GCP)

December 11, 2017 Leron Amin 48 Comments

Facebook4TweetLinkedInGoogle+Email

For many application on Google Cloud, phpMyAdmin is only accessible via your local machine using an SSH tunnel. This is done as a security precaution, which you will find configured in the WordPress Bitnami stack on Google Cloud Platform.

In this tutorial you will learn how to use puTTY as an SSH client in order to establish a secure shell (SSH) connection between your server and your local machine. This secure connection will allow you to connect to your server’s phpMyAdmin page in order to safely make changes to your website’s database.

Before getting started with this tutorial, you should have already installed puTTY, which is the SSH client that you will be using in this tutorial. Also, you should have already launched an application on Google Cloud Platform, such as WordPress Bitnami, which will be used as the example in this tutorial.

There are 5 steps in this tutorial:

  • 1. Download puTTY

  • 2. Generate SSH Keys

  • 3. Configure Public Key

  • 4. Configure puTTY

  • 5. Connect to phpMyAdmin

1. Download puTTY

access phpmyadmin ssh tunnel download putty
The first step in this tutorial is to download puTTY. Putty is the SSH client that we will use in this tutorial to establish the connection between our Google Cloud virtual machine and our local machine.

2. Generate SSH Keys

access phpmyadmin ssh tunnel generate ssh key
Open up the application called puTTYgen. This is the application that you will use to generate a public and private SSH key pair.
access phpmyadmin ssh tunnel save key files
After the SSH keys have been generated, change the key comment to Bitnami, then save the private and public key files to your computer.

3. Configure Public Key

access phpmyadmin ssh tunnel click on vm instance
Next, go to your Google Cloud Platform compute engine VM Instances page, and click on the instance that you are configuring. This will open the vm instance settings page.
access phpmyadmin ssh tunnel click on edit button
After opening the VM instance details page, click the edit icon at the top of the page.
access phpmyadmin ssh tunnel paste ssh public key
Scroll down to the SSH Keys section of the page and click the Show and Edit link. Then, from your puTTY Key Generator window, copy your public key text and paste it into the SSH key text box.
access phpmyadmin ssh tunnel save settings
Scroll to the bottom of the page and click the Save button.

4. Configure puTTY Settings

4.1 Session settings

access phpmyadmin ssh tunnel copy ip address
Open the main puTTY application (it’s a separate application). In the Session section of the puTTY category column, paste the External IP Address of your Google Cloud Virtual Machine into the Host Name (or IP address) field and the Saved Sessions field. Next, click the Save button to add the IP address to your saved sessions.

4.2 Auth settings

access phpmyadmin ssh tunnel upload private key
Navigate to the Auth section of puTTY under the SSH column. Click the Browse button to specify the path to your private key file.

4.3 Tunnels settings

access phpmyadmin ssh tunnel port forwarding
Navigate to the Tunnels section of puTTY under the SSH column. Enter 8888 as the Source port, and localhost:80 as the Destination, then click the Add button.

NOTE: If your domain is configured with SSL, then enter
localhost:443 as the Destination

4.4 Data settings

access phpmyadmin ssh tunnel auto login username
Navigate to the Data section under the Connection column. In the Auto-login username field, enter bitnami.

4.5 Session settings

access phpmyadmin ssh tunnel save configuration settings
Navigate back to the Session section at the top of the category list. Next, click on the IP address is the text box in order to select it, then click on the Save button to save your settings. Next, click the Open button at the bottom of the page to open the SSH tunnel. If you see an alert message window pop-up when connecting, click the Yes button in the alert message window.
access phpmyadmin ssh tunnel open tunnel
After clicking the Open button, you should see a terminal window pop up showing the connection between your local machine and your server.

5. Connect to phpMyAdmin

access phpmyadmin ssh tunnel open phpmyadmin
Now that the SSH tunnel has been configured, the last step is to open a new browser window and paste the following text into the URL bar: http://127.0.0.1:8888/phpmyadmin/. This will open up phpMyAdmin.

NOTE: If your domain is configured with SSL, then enter https://127.0.0.1:8888/phpmyadmin/ into the URL bar.

Did it work?

Now that you’ve configured the settings for both the puTTY Client and your Google Cloud VM instance, you can open the SSH tunnel at any time by clicking on the Open button on the Session page.

If you have any questions or comments, please post them below!

Thanks,

signature

Related Posts

  • How to Forward Zoho Mail Accounts to Gmail
  • How to Migrate WordPress Installations
  • Free SSL Certificate Setup for WordPress on Google Cloud (Bitnami)
  • Setup Custom Domain Email on Google Cloud Platform
  • How to Fix SSH (Linux Shell) Permission Errors on Google Cloud
  • WordPress on Google Cloud Tutorial 2017
Facebook4TweetLinkedInGoogle+Email

Filed Under: GCP Networking, GCP WordPress, Google Cloud Platform Tagged With: bitnami, google cloud, ssh, wordpress

Comments

  1. Noer Loekman says

    October 21, 2018 at 8:22 pm

    Great tutorial. But how did I know the username and password of myphpadmin?

    Thanks

    Reply
    • Leron Amin says

      October 21, 2018 at 10:59 pm

      Hi Noer,

      The password is generated when you first launch the WordPress instance.

      On Google Cloud, you can view the phpMyAdmin credentials by navigating to Marketplace > Your Solutions. From there, click on the WordPress instance that you deployed in order to show the phpMyAdmin username and password.

      Hope this helps and let me know if you have any questions,
      Joe

      Reply
  2. Akash Sarawagi says

    October 6, 2018 at 12:55 am

    thanks buddy for your help. 🙂
    Well your tutorials are really very very helpful for beginners .
    I am using bitnami wordpress as vm instance in google cloud. I used then putty and did the all required steps as mentioned in tutorial. I was successfully able to access phpmyadmin.
    But after installing ssl. when ever i try to access http://127.0.0.1:8888/phpmyadmin/index.php it redirects to my domain and i get error message saying “For security reasons, this URL is only accessible using localhost (127.0.0.1) as the hostname.”
    Kindy help me

    Reply
    • Leron Amin says

      October 8, 2018 at 2:57 pm

      Hi Akash,

      If you’re using SSL, you will have to use https://127.0.0.1:8888 instead of http://127.0.0.1:8888

      Check out this comment here from Georgi where he goes into detail about the process!

      Let me know if you have any questions,
      Joe

      Reply
  3. BIJAY says

    September 10, 2018 at 7:36 am

    i am getting redirected to the site url whenever i am accessing it through localhost please help me

    Reply
    • Leron Amin says

      September 10, 2018 at 9:00 am

      Hi Bijay,

      Try accessing the site through another browser aside from Google Chrome.

      If that’s not an option, try viewing the site through a private window.

      If it still doesn’t work, please provide additional details of the errors you’re experiencing and I will see how I can help.

      Joe

      Reply
  4. Rudy Hettrick says

    August 22, 2018 at 9:43 pm

    Hi Joe,

    Thank you so much for all your wonderful tutorials. I’m running a multisite (Click to Deploy)right now and crashed the site because I changed the domain to https before running certs first. I think that’s what happened. LOL! Anyways, I’m trying to open phpmyadmin, I can login to Apache fine by following the above instructions, but I still can’t connect to phpmyadmin, trying both http an https to login. The instance details do not show a phpmyadmin user or password either. So I’m not sure what to do next. If there’s another way even, to revert my domain back to http:// for now, then I am open to options. Thanks!! 🙂

    Reply
    • Leron Amin says

      August 23, 2018 at 12:48 pm

      Hey Rudy,

      Thanks for the feedback – I’m glad the tutorials were helpful to you! 🙂

      Comment out (aka put a # to the very left of the text) the redirect from your wordpress.conf file (step 7) and also temporarily undo what was done in step 6 (comment out the SSL certs, and uncomment the snakeoil certs).

      Then, follow the section from this guide in the section titled ‘Edit functions.php’, add add your WordPress URL without https. Save the changes and restart your server. Then try viewing your site in a different browser or through a proxy, as your default browser will try to serve the cached page with the https prefix.

      Hope this helps and let me know if you have any questions,
      Joe

      Reply
      • Rudy Hettrick says

        August 25, 2018 at 11:16 am

        Hi Joe! Thanks for your help. I ended up relaunching a new Click To Deploy Multisite instance. I pointed my Godaddy Domain to GC and changed the url in the settings and now the site is down and I still can’t access PHPMyAdmin for some reason. I followed the instructions I’m pretty sure. I just don’t know why I can’t. I enabled FTP permissions and have access there. Just no access to phpmyadmin. What am I missing?

        Reply
        • Leron Amin says

          August 25, 2018 at 11:24 am

          Hi Rudy,

          It looks like the site is up (primarlweb.ca), but the /phpmyadmin URL is returning a not found.

          Did you remember to check the box “Install phpmyadmin” when you deployed the instance?

          Talk to you soon,
          Joe

          Reply
  5. Duy Anh says

    July 28, 2018 at 2:00 pm

    Hi, Thank you for your guide. I want to ask how i can update php version to 7.1 in Google Cloud ?

    Thank you for your help

    Reply
    • Leron Amin says

      July 30, 2018 at 9:38 am

      Hi Duy,

      I wouldn’t recommend doing the upgrade unless you are an experienced sysadmin – so proceed at your own risk and with caution.

      If you’re using Bitnami, you will most likely have to deploy a new WordPress LAMP stack with the upgraded components and migrate your website manually or with the All-in-One WP Migration plugin.

      If you’re using Click-to-deploy or a similar Apache configuration, you can upgrade the components manually. Check out the following resources from Ayesh, and LinuxTechLab.

      Remember to create backups of your website before making any changes.

      Best of luck,
      Joe

      Reply
  6. Ekaluk Pongsrihadulchai says

    July 14, 2018 at 3:24 am

    after I reached http://127.0.0.1:8888/phpmyadmin/
    It showed me the red screen with error below. could you help ?

    Error during session start; please check your PHP and/or webserver log file and configure your PHP installation properly. Also ensure that cookies are enabled in your browser.

    session_write_close(): write failed: No space left on device (28)

    session_write_close(): Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/opt/bitnami/php/tmp)

    Reply
    • Leron Amin says

      July 14, 2018 at 2:39 pm

      Hi Ekaluk,

      One of your directories is full, and therefor can’t be written to.

      In your terminal, run the following command to view which directory is full:

      df

      You will have to increase the size of the disk in order to be able to write to it. Unfortunately, I don’t have a tutorial on that subject, but you can check the Google Cloud docs for instructions on how to resize persistent disks.

      The resizing process, as documented in the link above, is a relatively straightforward process; however, it requires that you stop your instance.Make sure that you reserve a static IP address for your VM instance before stopping it.

      Hope this helps and let me know if you have any questions,
      Joe

      Reply
  7. Vincent says

    June 6, 2018 at 10:18 am

    I am using an online server,can I use this tutorial?

    Reply
    • Leron Amin says

      June 6, 2018 at 11:20 am

      Hi Vincent,

      Yes, you can. However, with most applications you can access phpMyAdmin directly at yourwebsite.com/phpmyadmin – therefor there is no need to implement the steps outlined in this tutorial. That being said, if you’re using one of Bitnami’s stacks then you will indeed find this tutorial useful for your online server.

      Let me know if you have any questions,
      Joe

      Reply
      • Vincent says

        June 6, 2018 at 11:31 am

        I am using phpmyadmin on my server,I need to connect the database with google cloud server,I don’t know the steps or how everything supposed turned to work,I have been stuck for 2 weeks and I cant find any clear tutorial on exactly on what to do…

        Reply
        • Leron Amin says

          June 6, 2018 at 12:47 pm

          Hi Vincent,

          Which application are you running? WordPress?

          If so, I would avoid using Bitnami’s stacks and instead use Click-to-deploy stacks because they are easier to configure. Using Click-to-deploy will allow you to access phpMyAdmin directly from your website’s url (yourwebsite.com/phpmyadmin).

          Hope this helps and let me know if you have any questions,
          Joe

          Reply
          • Vincent says

            June 6, 2018 at 3:30 pm

            Its just a normal website with an online database and I need to connect the database with google cloup plartform.

          • Leron Amin says

            June 6, 2018 at 3:45 pm

            Hi Vincent,
            This tutorial is not related to what you are trying to accomplish, and I don’t have any tutorials on the subject.
            Your database credentials are stored in a configuration file, which will be different depending on the application stack that you’re running.
            This Magento tutorial gives an overview of the general process (for Magento specifically), but like I said, the steps will be different depending on your application stack.
            Good luck and I hope this information helps,
            Joe

  8. Bob says

    June 4, 2018 at 11:13 am

    Thanks! All went great!
    however now am phpmyadmin, what’s the user name and password supposed to be ?

    Reply
    • Leron Amin says

      June 5, 2018 at 8:55 am

      Hi Bob,
      Your username and password credentials for phpMyAdmin are created when you first launch the instance. You can view them from your Google Cloud dashboard by clicking the hamburger menu in the upper-left hand corner of the screen and navigating to Cloud Launcher > Your Solutions and then selecting your deployment.
      Let me know if you have any questions,
      Joe

      Reply
      • C.L. says

        August 14, 2018 at 8:13 am

        Hi Joe,

        Once again your tutorial has been great and me without having any knowledge and background in this field has managed to successfully reach phpmyadmin page.

        However, i also faced the same situation whereby i dont know how to log on. Googled and watched YouTube and there seems to be tons of solutions like username=root, password=null, when that didnt work, change the config.inc.php to no password etc., but all these still did not work out. Saw this thread and looked into Google Cloud dashboard, but there isnnt this Cloud Launcher option available. Can you please shed some lights on this? Thanks!

        Reply
        • Leron Amin says

          August 14, 2018 at 11:33 am

          Hi C.L.,

          From the Google Cloud sidebar menu, navigate to Marketplace > Your Solutions, then click on the deployment for your application. This will show you a dashboard with your phpmyadmin username and password.

          Let me know if you have any questions,
          Joe

          Reply
          • C.L. says

            August 14, 2018 at 7:18 pm

            Hi Joe,

            Thanks again, managed to locate the dashboard. However, keyed in the admin user and admin password (temporary), still got this message “mysqli_real_connect(): (HY000/1045): Access denied for user ‘user’@’localhost’ (using password: YES) ”

            and noticed that the site address and admin URL do not show my wordpress URL, but both are showing exclamation mark in red instead

          • C.L. says

            August 14, 2018 at 7:28 pm

            Hi again Joe,

            Again, just moments after submitting my last reply, i’ve managed to find the solution, simply by using “root” as the username instead of “user” as what showed on the Google Cloud dashboard, and using the same admin password (temporary).

            Thanks again so much!

          • Leron Amin says

            August 14, 2018 at 8:33 pm

            I’m glad to hear you got it working – and thanks for sharing the solution!

  9. Crystal says

    April 12, 2018 at 4:41 pm

    Just wanted to thank you for all the work you have put into this site. I am in the process of building and launching my business website using Bitnami WordPress on the gcp and I have you to thank for getting me this far. You have the single best, most complete start to finish walkthrough for someone like me that knew absolutely nothing at the start of this endeavor. Whenever I googled how to do something your site came up again and again, with exactly what I needed, presented in a way that is easily understood. I eventually just pinned your site in my browser to save time. My site is up, working correctly with the correct domain, my theme is installed and my dummy data is plugged in. I’m all set to customize the site and input my own content. You deserve an awesomeness award for sure!

    Reply
    • Leron Amin says

      April 12, 2018 at 5:39 pm

      Thanks so much for the positive feedback Crystal – I love hearing stories from people who were successful in migrating their websites to the cloud.
      Don’t hesitate to reach out if you ever have any questions or comments related to any of the tutorials! 🙂
      Talk to you soon,
      Joe

      Reply
  10. Anton says

    April 4, 2018 at 1:53 am

    Thanks for this great tutorial!!

    though at first it stressed me out because whenever I access local:8888/phpmyadmin I always redirected to home page of the actual site. and all the tips in the comment section didn’t worked for me. I use SSL on my site by the way.

    But I finally can now access phpmyadmin by excluding phpmyadmin from force always HTTPS.
    and then I can access phpmyadmin with port 80, while my site still always HTTPS.

    Reply
    • Leron Amin says

      April 6, 2018 at 4:10 pm

      Awesome – sounds like a great workaround! Thanks for sharing the details!

      Reply
  11. tse says

    March 14, 2018 at 12:33 am

    Dear Leron,

    Thank you for the great tutorial, it helps me a lot.
    However, i would like to ask 1 question that i want to upload my themes / plugins through Filezilla, and where should i locate the themes / plugins file?

    thanks

    Reply
    • Leron Amin says

      March 15, 2018 at 12:39 am

      Hi Tse,

      I’m glad the tutorial helped you!

      For the Bitnami stack, the directory is located at /apps/wordpress/htdocs/wp-content

      For Click-to-Deploy, the directory is located at /var/www/html/wp-content

      Let me know if you have any questions,
      Joe

      Reply
  12. Geoff says

    March 7, 2018 at 2:05 pm

    I have configured the install (Bitnami WP) to use a URL instead of the IP, and have the free SSL enabled (your tutorials – great resource!!!), and when I try to tunnel in, it redirects to the URL, not 127.0.0.1. Any advice on getting that redirect to be avoided?

    Reply
    • Leron Amin says

      March 8, 2018 at 12:37 pm

      Hi Geoff,

      I’m not sure how to get that working. You’re not the first person to complain of that issue, but I’m also not sure how they got it resolved.

      My advice would be to check StackOverflow and try contacting Bitnami support to see if they can help since the issue seems to be unique to their WordPress stack.

      Please let me know if you find the solution.

      Thanks,
      Joe

      Reply
      • Geoff says

        March 9, 2018 at 7:51 am

        Found it – if you set up the connection in Terminal using ssh -N -L 8888:127.0.0.1:443 -i ~/.ssh/wherever/keyfile name@[my ip address] then connect to https://127.0.0.1:8888/phpmyadmin/ it seems to be able to bypass the IP redirect.

        Reply
        • Leron Amin says

          March 10, 2018 at 8:50 am

          Hi Geoff,

          Thanks for finding this solution – I know a lot of users will find it helpful!

          Best regards,
          Joe

          Reply
  13. Isabel Da Guerra says

    January 3, 2018 at 2:39 am

    Hiya again, 😉

    I was determined to set up my PHPAdmin… Followed your steps but still got access error. But eventually managed between your tutorial AND bitnami’s …

    —————Kept getting this WARNING MESSAGE——————
    “Your connection is not private
    Attackers might be trying to steal your information from 127.0.0.1 (for example, passwords, messages or credit cards). Learn more
    NET::ERR_CERT_COMMON_NAME_INVALID”
    ————————————————

    >> Clicked on the ‘Not Secure’ on —-Chrome browser—- and read ‘Certificate Invalid’ ???
    …but test on https://www.ssllabs.com/ssltest/ passed with ‘A’ level ???

    Talk about being confused huh!? HeLp 😉

    >> Clicked on the ‘Learn more’ in —-WARNING MESSAGE—-

    Long story short, it said my site was not secure but I could still click on… ‘Proceed to 127.0.0.1 (unsafe)’ and voila’ got to unsecure https://127.0.0.1:8888/phpmyadmin/

    Next step >> Login

    Now not sure but, I could’ve used the ‘mysql -u root -p’ command for this to have worked a couple months back… as seen at ‘How To Connect To The MySQL Database?’
    https://docs.bitnami.com/google/apps/wordpress/#how-to-force-https-redirection

    PROBLEM: Login to PHPAdmin ‘bitnami’ username was not accepted,
    FIXES: As per instruction on VIDEO link below – username ‘root’ and ‘password inside my VM instance’ was accepted.

    https://docs.bitnami.com/google/apps/wordpress/#accessing-phpmyadmin-on-windows
    ————————————————-

    I have a question though, with regards to:
    This server could not prove that it is 127.0.0.1; its security certificate is from mysite .com. This may be caused by a misconfiguration or an attacker intercepting your connection. Proceed to 127.0.0.1 (unsafe)

    Is there anything I should be worried about or is there any alternative fixes for this?

    Thank you again 😉

    Reply
    • Leron Amin says

      January 3, 2018 at 6:46 pm

      Hi Isabel,
      Just choose the option for “trust anyway” – it will not pose a security issue.
      This is because you are accessing your website’s back-end through localhost, so there is no third party validating the authenticity of the certificate.

      Reply
      • Isabel Da Guerra says

        January 4, 2018 at 9:00 am

        Thank you Leron, understood and at easy … 😉

        Reply
  14. Dev says

    November 13, 2017 at 9:18 am

    Thank you for the great tutorial Leron. I would like to adapt this solution for those who connect to phpmyadmin on macOS or Linux. Once you have the keys Just open terminal and

    If you are not using SSL use following code:

    ssh -N -L 8888:127.0.0.1:80 -i [paste path to key file .pem] bitnami@[paste your ip address.]
    and go to http://127.0.0.1:8888/phpmyadmin/

    If you are using SSL use following code:

    ssh -N -L 8888:127.0.0.1:443 -i [paste path to key file .pem] bitnami@[paste your ip address.]
    and go to https://127.0.0.1:8888/phpmyadmin/

    Reply
    • Leron Amin says

      November 13, 2017 at 9:21 am

      Hi Dev,

      Thanks so much for sharing this!

      A lot of people have been asking about how to adapt this tutorial for Mac, so I will point them to your comment!

      Talk to you soon,
      Joe

      Reply
    • Benjamin says

      December 27, 2017 at 8:05 pm

      Hello Dev,

      I have tried this but doesn’t work; nothing happens after I get prompted to enter my passphrase as follows:
      Enter passphrase for key ‘/home/benjaminwaller/.ssh/google_compute_engine’:

      It enters to the next line and just sits there!
      I thought it might have been because I had the firewall check on in my GCP instance but I turned it off and still can’t connect!

      I used this the following command without the ‘.pem’ because I got an “No such file or directory.
      Permission denied (publickey). error when adding that.
      ssh -N -L 8888:127.0.0.1:443 -i ~/.ssh/google_compute_engine benjaminwaller@[my ip address.]

      The permissions is set to the highest at 775.
      Can anyone suggest someone I’m missing?
      Best regards,
      Ben

      Reply
      • Benjamin Waller says

        January 12, 2018 at 10:01 pm

        UPDATE: I figured this out.
        I needed to create the SSH tunnel after doing gcloud auth login. I was SSH’ing into my vm with this command (gcloud compute ssh moodle-1-vm –zone australia-southeast1-a) and then trying to SSH to my machine while connected via SSH. I found out after sharing a screenshot of my terminal commands on the Bitnami Community forum https://community.bitnami.com/
        Just wanted to share my issue and solution for others with little experience like me.

        Best regards,
        Ben

        Reply
        • Leron Amin says

          January 12, 2018 at 10:25 pm

          Awesome! Thanks for sharing the update Ben! 🙂

          Reply
  15. Georgi says

    November 10, 2017 at 4:36 am

    Hi Leron
    here how I fixed:
    L8888 localhost:443 or L8888 127.0.0.1:443 instead of L8888 127.0.0.1:80
    and then
    https://127.0.0.1:8888 instead of http://127.0.0.1:8888
    and all is working.
    Thank you for your very helpful work!
    Best regards

    Reply
    • Leron Amin says

      November 10, 2017 at 8:07 am

      Hi Georgi,
      Thanks for posting this! 😀
      These are very great tips for people configuring SSH tunnels with SSL configured!
      Talk to you soon,
      Joe

      Reply
  16. Leron Amin says

    November 9, 2017 at 2:47 pm

    Did this tutorial work for you?
    Please share your questions and comments below! 😀

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Want Exclusive Tutorials?

Advertisement

Contact | Sitemap | Legal | Privacy Policy | Affiliate Disclosure
      Copyright © 2017 - 2019 One Page Zen
Share this Article

Email sent!