Generating a Certificate Signing Request

When applying for a secure certificate you will need to generate a certificate signing request (CSR). If you are renewing an existing certificate you might want to keep your existing private key, if it’s a new certificate then you will probably need to create a new private key.

If you have previously registered a secure cert and nothing has changed since then, you can even re-use the existing CSR. The most important part of a CSR is the embedded public key, which must correspond to your private key, hence why it only really needs to change if you have changed private key.

What is in a Certificate Signing Request?
A CSR can contain the following information:

  • Domain name (or person’s name)
  • Address details
  • E-mail address
  • Public Key

When you send the CSR to a CA (certificate authority), they will use the information embedded within it to create you a full certificate, which has been signed by them. Some CAs will let you change the address information before generating the certificate.

You can decode a CSR with the following command:

openssl req -in old/ -text -noout
Certificate Request:
       Version: 0 (0x0)
       Subject: C=GB, ST=Hampshire, L=Aldershot, O=Fubra Ltd,
       Subject Public Key Info:
           Public Key Algorithm: rsaEncryption
           RSA Public Key: (1024 bit)
               Modulus (1024 bit):
               Exponent: 65537 (0x10001)
   Signature Algorithm: md5WithRSAEncryption

Generating a new CSR and a new private key
To create a brand new private key and certificate signing request just run:

openssl req -new -nodes -keyout newprivate.key -out server.csr

Generating a new CSR with an existing private key

If you need to generate a certificate signing request from an existing private key, you can do so with the following command:

openssl req -new -key existingprivate.key -out server.csr

Using an existing CSR with an existing private key
You don’t need to run any new commands, just send your existing CSR to the certificate issuer.

When sudo echo ‘test’ > /root/test gives permission denied

If you get a permission denied error when trying to redirect the output of a sudo command then the reason for this is normally because the superuser permissions only apply to the first part of the statement, e.g. the echo command. They do not carry through to the bash redirection.

paul@backups:~$ sudo echo 'test' >> /root/test
-bash: /root/test: Permission denied

One way to get round this is to use the tee command, as follows:

echo 'test' | sudo tee -a /root/test

Note that the -a switch means append to the file if it already exists.

rtorrent: Error in option file

My bit torrent client of choice is rtorrent, which runs from the command line. I have been using it without problems for months, but today it stopped working and gave an error instead:

rtorrent: Error in option file: ~/.rtorrent.rc:4: Not a value

It seems that the rtorrent developers have made some changes to the way it handles its config files, and they are not backwards compatible. So when Ubuntu upgraded my rtorrent package, it broke.

To fix this you must check all your configuration settings against the new config syntax. You can see a list of valid configuration settings in /usr/share/doc/rtorrent/examples/rtorrent.rc

There were a number of settings I needed to change, but a common one that will probably cause a lot of people problems is the upload / download rate.

Old Syntax

upload_rate = 25KB
download_rate = 400KB

New Syntax

upload_rate = 25
download_rate = 400

Killing Processes

Previously if I had wanted to kill a bulk list of mysql processes I would have done something like:

ps auxww | grep ^mysql | awk '{print $2}' | xarg kill -9

Today I discovered two really handy commands that make listing and killing processes a lot easier, pkill and pgrep.

You can achieve the same result as above with:

pkill -9 -u mysql mysql

This will kill all processes owned by the mysql user that have mysql in their name.

Setting up asterisk-gui on Ubuntu

Tonight I had a go at installing Digium’s asterisk-gui. I followed some instructions from Asterisk Guru, but then had to apply a fix at the end because the static-http folder was in the wrong place.

Installation Instructions

Download the asterisk-gui source code from SVN:

mkdir -p ~/downloads/asterisk-gui
cd ~/downloads/asterisk-gui
svn checkout .

Compile the source code:

./make install

Backup your asterisk config:

cp -r /etc/asterisk /etc/asterisk.backup

Install the sample settings if you wish (this adds things like a list of VOIP providers to use as a PSTN gateway).

./make samples

Edit /etc/asterisk/manager.conf to enable the web management interface and to add a user:

enabled = yes
webenabled = yes
secret = YoUrPaSwOrD
read = system,call,log,verbose,command,agent,user,config
write = system,call,log,verbose,command,agent,user,config

Edit /etc/asterisk/http.conf to enable asterisk’s mini webserver. If you are accessing from your local machine use otherwise you might want to bind to a public ip, but be aware this is less secure.


Run make checkconfig to verify your configuration settings:

./make checkconfig

I then had to do an additional step to link the static http scripts folder to inside /usr/share/asterisk as it seems asterisk was looking in here instead of /var/lib/asterisk/

sudo ln -s /var/lib/asterisk/static-http/ /usr/share/asterisk/

After that you should be able to login to the control panel at (replacing the IP address with whichever one you chose).

Missing asterisk config files in Ubuntu / Debian

If you install Asterisk on Ubuntu via apt-get, and then remove it and re-install again, you may find that you are missing the all the config files in /etc/asterisk.

This is a bug in the debian asterisk package that means that the config files are deleted when you remove the asterisk package even though they are part of the asterisk-config package.

To fix it simply run the following commands: (NB: This will nuke any asterisk installation you have)

sudo dpkg --purge asterisk
sudo dpkg --purge asterisk-config
sudo apt-get install asterisk-config
sudo apt-get install asterisk

Installing phpMyAdmin Advanced Features on Ubuntu


To install the advanced features of phpMyAdmin you have to create a special control database that PMA uses to store bookmarks and relationships etc… PMA comes with a script called create_tables.sql that contains the relevant sql statements to set these tables up. Normally, when you install phpMyAdmin directly from source, this create_tables.sql script can be found in the scripts sub-folder.

Today I was feeling lazy so I decided to use apt-get to install PMA on my Ubuntu machine. However, when I went to enable advanced features, the scripts sub folder was pretty much empty (except for a setup.php script). It seems that with the debian package the advanced feature scripts have been moved to /usr/share/doc/phpmyadmin/examples – It took me ages to work this out, so hopefully this post might save someone some time!

Firstly, unzip and run the create_tables.sql file:

cd /usr/share/doc/phpmyadmin/examples
sudo gunzip create_tables_mysql_4_1_2+.sql.gz 
mysql -u root -p < create_tables_mysql_4_1_2+.sql

Then setup a user/password for phpMyAdmin to use:

mysql -u root -p -e 'GRANT SELECT, INSERT, DELETE, UPDATE ON `phpmyadmin`.* TO 'pma'@'localhost' IDENTIFIED BY "password"'

Then edit the config file, and uncomment the advanced features options for your chosen server, and add the user / password you setup in the previous step. If you haven't edited this file before you may need to also uncomment the rest of the server definition.

sudo vim /etc/phpmyadmin/

Encoding mp3 audio with ffmpeg on Ubuntu Hardy

If you already have ffmpeg installed (without mp3 support), then firstly uninstall it.

MP3 support isn’t included with ffmpeg in the default Ubuntu repositories so to get it you have to enable the Medibuntu repos (assuming this is legal in your area).

sudo wget -O /etc/apt/sources.list.d/medibuntu.list
wget -q -O - | sudo apt-key add - && sudo apt-get update

Then you can install ffmpeg and the libmp3lame codec (part of the libavcodec package)

sudo apt-get install ffmpeg
sudo apt-get install libavcodec1d

You can verify the dependencies of ffmpeg with ldd

paul@paul:~/Videos$ ldd /usr/bin/ffmpeg =>  (0xb7f07000) => /usr/lib/ (0xb7e72000) => /usr/lib/ (0xb7997000) => /usr/lib/ (0xb798c000) => /lib/tls/i686/cmov/ (0xb7967000) => /lib/tls/i686/cmov/ (0xb794f000) => /lib/tls/i686/cmov/ (0xb7800000) => /usr/lib/ (0xb77eb000) => /usr/lib/ (0xb77e6000) => /usr/lib/ (0xb77d6000) => /lib/tls/i686/cmov/ (0xb77d2000) => /usr/lib/ (0xb77c7000) => /usr/lib/ (0xb77ba000) => /usr/lib/ (0xb7725000) => /usr/lib/ (0xb76db000) => /usr/lib/ (0xb76b3000) => /usr/lib/ (0xb75ba000) => /usr/lib/ (0xb74a2000) => /usr/lib/ (0xb7417000) => /usr/lib/ (0xb7406000)
	/lib/ (0xb7f08000) => /usr/lib/ (0xb73ff000) => /usr/lib/ (0xb7318000) => /usr/lib/ (0xb7316000) => /usr/lib/ (0xb72fe000) => /usr/lib/ (0xb72fa000) => /usr/lib/ (0xb72f5000)

It should then let you encode videos with mp3 audio…

ffmpeg -i jonathan-davis-news24-2008-01-22.avi -f flv -s 400s220 -acodec mp3 -ar 44100 jd.flv

Setting up a PXE install for Linux

Installing Linux via PXE boot over a network can be a really nice way to do it and it is especially useful, if your client machine doesn’t have a CD / DVD drive. However, it can be a bit tricky to understand how it all works, so this post will hopefully explain what is going on, as well as show you how to set it up.

You will need:

  • A DHCP server
  • A TFTP server (tftpd-hpa)
  • vmlinuz and initrd.img from your distribution of choice
  • The PXELINUX.0 boot loader and a suitable config file

Install the TFTP server

Ensure you use the tftpd-hpa package, as PXELINUX requires that the boot server has a TFTP server which supports the “tsize” TFTP option. If you don’t use tftpd-hpa you will most likely see an error such as ‘TFTP server does not support the tsize option’

sudo apt-get install tftpd-hpa tftp-hpa xinetd

Configure xinetd to load TFTP

Create a new file called /etc/xinetd.d/conf/tftp and add the following contents:

service tftp
protocol        = udp
port            = 69
socket_type     = dgram
wait            = yes
user            = root
server          = /usr/sbin/in.tftpd
server_args     = /tftpboot
disable         = no

Create the /tftpboot folder, and ensure it is world readable. Then restart xinetd, and then test you can connect using tftp.

Set up the DHCP server

Add the following config to your /etc/dhcpd.conf file:

host pxeinstall {
# specify your client's MAC address
hardware ethernet 00:13:21:1F:F1:82; 
# give it an IP
#If the tftp server is on a different host to the DHCP server, specify its IP.
# path of the bootloader file, with tftpd-hpa it must be the absolute path
filename "/tftpboot/linux-install/pxelinux.0";

Then reboot dhcpd.

Setting up PXELINUX

PXELINUX is a SYSLINUX derivative, for booting Linux off a network server. Essentially, it is used to load a linux kernel of your choice on to your machine. You specify which kernel to load in a config file. You can download the latest pxelinux.0 file from You will need to extract it from the syslinux archive .

You are going to be creating a folder structure that will eventually look like this:


So, create a linux-install folder inside the /tftpboot folder. Inside this directory you should copy in pxelinux.0 (the PXE network boot loader) and create another folder called pxelinux.cfg. Inside pxelinux.cfg, create a file called default and copy in something like the following code:


Make a folder called pxelinux.cfg inside /tftboot/linux-install and then inside that create a file called default, with the following contents:

DISPLAY menu.msg


LABEL linux
        localboot 0

LABEL centos5.1
        KERNEL distros/centos5.1/vmlinuz
        APPEND initrd=distros/centos5.1/initrd.img ramdisk_size=6454 ip=dhcp

LABEL ubuntu8.04
        KERNEL distros/ubuntu8.04/linux
        APPEND initrd=distros/ubuntu8.04/initrd.gz ramdisk_size=6454 ip=dhcp

What this does is set up a boot prompt where you can choose to load any of the specified labels (kernels). In my example, I have used centos 5.1 and Ubuntu 8.04.

There is a 20 second timeout (200=20 seconds) and after this, it will load the default label.

The options we specify after each label direct the boot loader to the location of the kernel and the initrd files for that particular distro. NB: You must specify the path relative to the PXELINUX.0 file.

We have also specified menu.msg file – this just shows an ASCI menu to let people know what options they have. Unfortunately we could find a way to auto-generate a boot menu, so you need to edit the menu.msg manually every time you change the pxe config.

Linux Kernel and Initial Ram Disk

The only two files that are really needed to begin installing a distribution after PXELINUX loads are the compressed linux kernel and initial ram disk of your choice. You can define these as shown above in the pxelinux config. For ubuntu 8.04 they are called linux and initrd.gz, and can be found in the netboot folder of the ubuntu archive. For centos 5.1 they are called initrd.img and vmlinuz and can be found in the pxeboot images folder on any Centos Mirror. Once you have downloaded whichever ones you want to use, put them into your linux-install folder as shown in the directory structure above.


This is a really simple ASCII file that will be displayed as the boot menu. The one we use is as follows:

                          .-=-.          .--.
              __        .'     '.       /  " )
      _     .'  '.     /   .-.   \     /  .-'0c\0a
     ( \   / .-.  \   /   /   \   \   /  /    0c^0a
      \ `-` /   \  `-'   /     \   `-`  /
       `-.-`     '.____.'       `.____.'
  __ _ _ __   __ _  ___ ___  _ __   __| | __ _ 
 / _` | '_ \ / _` |/ __/ _ \| '_ \ / _` |/ _` |
| (_| | | | | (_| | (_| (_) | | | | (_| | (_| |
 \__,_|_| |_|\__,_|\___\___/|_| |_|\__,_|\__,_|


Choose one of the following labels in order to boot:
- linux (localboot)
- centos5.1
- ubuntu8.04

Upgrading to WordPress 2.5 with subversion

The quickest way to upgrade wordpress is via subversion. Assuming you had already installed your blog via subversion then you can upgrade using the following steps:

Backup your database
Since the wordpress db contains only MyISAM tables, you can backup with a simple file copy.

cd /var/lib/mysql
cp -Rp wordpress/ wordpressBACKUP

Switch to the latest subversion url
Just run the svn switch command. This will add, update and delete scripts as required to bring you to the latest version.

cd /path/to/your/blog
svn switch

Run the upgrade script
Finally, run the wordpress upgrade script, which upgrades the database and anything else it might need to do. Simply visit