How to secure an Ubuntu Server

Just going through the process of making an Ubuntu server PCI compliant and found this really nice post about how to secure an Ubuntu server. http://www.thefanclub.co.za/how-to/how-secure-ubuntu-1204-lts-server-part-1-basics

How to block a specific IP Address using UFW

The key to blocking a specific IP address with UFW is to make sure that the rule which blocks the ipaddress is applied before any allow rules. Because the firewalls rules are run in order – the block will no come into affect if it appears at the bottom. For example on most webserver you … Read more

How completely reconfigure apache2 configuration files

I tried upgrading one of our servers from Apache 2.2 -> Apache 2.4. It didn’t work so I purged the PPA but the configurations needed rolling back too (which ppa-purge command didn’t do). So, to completely remove Apache2 configuration files and reinstall them use the following command: and then had to also reinstall php5: Hope … Read more

How to rename a mysql database

There isn’t a simple command to rename a mysql database. You just need to create a new database and then rename all the tables like so: There is also an alternative method by dumping the old database and importing it again like so: I have found the second option to be alot faster both in … Read more

How to install wildcard certificates on multiple servers

If you have a wildcard certificate (for example *.randomhacks.co.uk) you might need to install it on multiple servers which host the different subdomains. Basically, don’t rekey the certificate for each server just copy the same keys and certificate files across all the servers. If you rekey the certificate each time then you will invalidate any … Read more

How to change /etc/apt/sources.list to use local apt-cache server in a single sed command

I’ve just installed an Ubuntu apt-cache server on our local network to speed up downloading packages each time we install or upgrade an Ubuntu computer. However, changing all the /etc/apt/sources.list file for every computer in the office is a real pain. Here is a simple command using sed which does this automatically for you: The … Read more

How to resize a qcow2 harddrive images

I usually make the hard drives on my virtual machines as small as possible to save disk space on the host. I do this because it is reasonably easy to resize them at a later date (especially if you using LVM). Anyhow here is a quick guide to resizing a qcow2 disk image. 1 – … Read more