Server Side:
- ssh to your remote machine
- Block direct access to your PHPMyAdmin and allow it for localhost only.
If you have a standalone PHPMyAdmin then go to the apache configuration file and add the following lines.
#Restricted the Access to phpMyAdmin
<Directory /var/www/html/project/path-to/phpMyAdmin>
Order Deny,Allow
Deny from all
Allow from localhost
</Directory>If you have installed the PHPMyAdmin then add lines I mentioned below in “PHPMyAdmin.conf” file, I mentioned the absolute path below.
#Restricted Access to phpMyAdmin
Order Allow,Deny
Allow from localhost
Path: /etc/apache2/conf-available/phpmyadmin.conf - However, we can still connect to our database via the SSH tunnel approach, as I have mentioned in the steps below in the section.
Client Side:
- The user would create an SSH session for a specific server. For instance, if my server’s host IP is 192.168.1.55, I’ll do the following course of action.
- ssh -L 8900:localhost:80 user@192.168.1.55, run this command on the client side(Local system)
- login with your SSH password
- Once logged in, you can access phpMyAdmin locally via … http://localhost:8900/phpmyadmin