Add an additional layer of security to the PhpMyAdmin login interface

by time news

MySQL It is the world’s most widely used open source database management system in the Linux ecosystem, and at the same time, it is difficult for Linux newbies to manage it from the MySQL prompt.

PhpMyAdmin, is a web-based MySQL database administration application, which provides an easy way for Linux newbies to interact with MySQL through a web interface. In this article, we will share how to secure the phpMyAdmin interface with password protection on Linux systems.

Simply adding the following lines to /etc/apache2/sites-disponible/000-default.conf in Debian o /etc/httpd/conf/httpd.conf in CentOS/RHEL/AlmaLinux will require basic authentication AFTER to confirm the security exception but BEFORE to access the login page.

Thus, we will be adding an extra layer of security, also protected by the certificate.

Add these lines to the Apache configuration file ( /etc/apache2/sites-available/000-default.conf o /etc/httpd/conf/httpd.conf ):

/etc/apache2/sites-available/000-default.conf – En Ubuntu


    Tipo de autenticación básico
    AuthName "Contenido restringido"
    AuthUserFile /etc/apache2/.htpasswd
    Requerir usuario válido

If you have RedHat, AlmaLinux, CentOS, etc…

/etc/httpd/conf/httpd.conf – On CentOS


    AuthType Basic
    AuthName "Restricted Content"
    AuthUserFile /etc/httpd/.htpasswd
    Require valid-user

then use htpasswd to generate a password file for an account that will be authorized to access the phpmyadmin login page. Read the article Create a protected directory for Apache. We will use /etc/apache2/.htpasswd y linuxparty in this case:

---------- En sistemas Ubuntu/Debian ----------
# htpasswd -c /etc/apache2/.htpasswd linuxparty

---------- En sistemas CentOS/RHEL ----------
# htpasswd -c /etc/httpd/.htpasswd linuxparty

enter Password twice and then change the permissions and ownership of the file. This is to prevent anyone not in the group from www data o apache can read .htpasswd:

# chmod 640 /etc/apache2/.htpasswd

---------- En sistemas Ubuntu/Debian ----------
# chgrp www-data /etc/apache2/.htpasswd

---------- En sistemas CentOS/RHEL ----------
# chgrp apache /etc/httpd/.htpasswd

Go to http:///phpmyadmin and you will see the authentication dialog before accessing the login page.

You will need to enter the credentials of a valid account in /etc/apache2/.htpasswd o /etc/httpd/.htpasswd to continue:

Asegure PhpMyAdmin con Password Protect

If the authentication is successful, you will be taken to the phpmyadmin login page.

You may also like

Leave a Comment