• Home
  • The Song
  • The Avatar
  • The Cat
  • Contact the Cat

Gyp the Cat dot Com

How to Secure phpMyAdmin on Ubuntu
Computers, internet

How to Secure phpMyAdmin on Ubuntu

Looking through my servers logs I noticed that I was attracting quite a lot of vulnerability scanners trying to access my phpMyAdmin directory.  Being ever the killjoy I am I had to secure the directories.  I’m already running Fail2Ban on Ubuntu but thought I should tighten it up even more to prevent any zero day exploits that may come out.

I’m already familiar with creating an SSH tunnel so thought if I tied everything down to localhost only, it meant that any attackers would first have to hack my SSH passwords before they could even access the MySQL databases.  But to be fair if that ever did happen I’d probably have more to worry about than just protecting my databases…

Also it had the knock on benefit that all my traffic with phpMyAdmin would be encrypted without the need of SSL certificates.  I’ve already made it so MySQL only listens to localhost for connections, so phpMyAdmin was the only vulnerability I had exposed.

Log on to your shell as normal.

From you command line type in:

nano /etc/phpmyadmin/apache.conf

From here we want to put a couple of lines in between the <Directory></Directory> tags:

Order Allow,Deny
Allow from 127.0.0.1

What this line boils down to is only accept connections from the loopback address (127.0.0.1 or localhost).  If a connection comes from anywhere that isn’t localhost then deny the connection.

My finished apache2.conf file looks like this between the <Directory></Directory> tags:

<Directory /usr/share/phpmyadmin>
        Order Allow,Deny
        Allow from 127.0.0.1
        Options FollowSymLinks
        DirectoryIndex index.php
        <IfModule mod_php5.c>
                AddType application/x-httpd-php .php
                php_flag magic_quotes_gpc Off
                php_flag track_vars On
                php_flag register_globals Off
                php_admin_flag allow_url_fopen Off
                php_value include_path .
                php_admin_value upload_tmp_dir /var/lib/phpmyadmin/tmp
                php_admin_value open_basedir /usr/share/phpmyadmin/:/etc/phpmyadmin/:/var/lib/phpmyadmin/
        </IfModule>
</Directory>

Reload apache:

sudo /etc/init.d/apache2 restart

Now load up your phpMyAdmin page from somewhere other than localhost and you should see a denied page.  To connect make sure you connect with SSH.  Take that script kiddies.

Related

Written by gyp - November 25, 2011 - 3503 Views
Tags | internet, phpmyadmin, security, ubuntu

You Might Also Like

ISC(2) CISSP Revision Notes – Access Control

November 25, 2013

How to Create a Websense Content Gateway (WCG) on CentOS

August 24, 2015

Saving Bandwidth the Postfix Way

October 26, 2010

No Comment

Please Post Your Comments & Reviews
Cancel reply

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

Previous Post
Next Post

Latest Posts

  • How to Convert CSV to Parquet Easily with Python on Linux Shell
  • Kusto Geolocation IP Lookup
  • Monitoring Tor Usage in Azure Sentinel, ASC, MDATP and ALA
  • HTTP to HTTPS Redirect on Azure CDN
  • Strongswan IPSec (Including Cryptomap) to Microsoft Azure Virtual Network Gateway
  • Black Ops 3 NAT Type Strict & PS4 NAT Type 3 with pfSense Fixed!
  • Sorry for the lack of posts
  • How to Block Internet Access with Group Policy (GPO)
  • Enforcing Microsoft Office 365 and Azure Tennancy with McAfee Web Gateway (MWG)
  • Scanning Subnet for Issuing Certificate Authority with OpenSSL

Top Posts & Pages

  • How to Block Internet Access with Group Policy (GPO)
    How to Block Internet Access with Group Policy (GPO)
  • How to Configure Windows 2012 NPS for Radius Authentication with Ubiquiti Unifi
    How to Configure Windows 2012 NPS for Radius Authentication with Ubiquiti Unifi
  • Kusto Geolocation IP Lookup
    Kusto Geolocation IP Lookup
  • Tinyproxy A Quick and Easy Proxy Server on Ubuntu
    Tinyproxy A Quick and Easy Proxy Server on Ubuntu
  • Monitoring Tor Usage in Azure Sentinel, ASC, MDATP and ALA
    Monitoring Tor Usage in Azure Sentinel, ASC, MDATP and ALA
  • How to DNSPerf on Ubuntu 14.04 with Installation and Quick Start
    How to DNSPerf on Ubuntu 14.04 with Installation and Quick Start
  • How to Add Different Disclaimers using alterMIME and Postfix based on Domain
    How to Add Different Disclaimers using alterMIME and Postfix based on Domain
  • Blocking Countries on Nginx without the GeoIP Module
    Blocking Countries on Nginx without the GeoIP Module
  • How to Enable Squid Anonymous Stealth Mode
    How to Enable Squid Anonymous Stealth Mode
  • Configuring Suite B, VPN-A and VPN-B in IPSec with Strongswan
    Configuring Suite B, VPN-A and VPN-B in IPSec with Strongswan

Tags

apache2 azure azure log analytics blops business centos cheating cissp cloudflare cryptography dns game google gyp internet iphone ipsec isc linux mac marketing microsoft mw2 mx mysql nginx pfsense postfix proxy ps3 qualification radius revision security seo smtp socks squid ssh strongswan tinyproxy ubuntu windows 2012 wordpress xdecrypt.com
Gyp the Cat dot Com

Some rights retained Gyp the Cat Dot Com