A chronological documentation test project, nothing serious, really!

26 Sep 2007 Advanced APT user tricks

Debian/Ubuntu apt-get tricks.


Install software

apt-get install foobar

Search software

apt-cache search foobar

You can query files to see which packages own them, or query packages to see which files own them.

Installing apt-file

apt-get install apt-file

Build apt-get file information cache

apt-file update

Query through the packages to determine which package contains the file

apt-file search mysqld

Query the other way around, you know the package name and would like info about all the files which are provided by a given pacage:

apt-file list mysqld

List all installed software/packages

dpkg --get-selections > software.txt

That will save your installed list to a file called software.txt. That list is every piece of software required to reproduce the state your PC is currently in.
Another way to get a full list of installed software is to run the command

dpkg --list

To restore a PC the list above

# dpkg --set-selections < software.txt
# apt-get dselect-upgrade

Clearing up space
Delete archived packages that are considered old.

# apt-get autoclean

Delete all archieved packages

# apt-get clean

Remove every file from a package

apt-get remove foobar --purge

Tags: , , , , ,

Posted by

09 Sep 2007 Setting up an SSL server with Apache2 on Debian

With the introduction of the Apache2 packages in Debian it is much simpler to create and use a secure SSL protected webserver than in the old days with Apache 1.3, here we’ll show how it is done. If you have Apache 2.x installed already then you’re good to go as you don’t need anything extra installed.

If you haven’t got it installed then you can do so easily:

earth:~# apt-get install apache2
Reading Package Lists... Done
Building Dependency Tree... Done
The following extra packages will be installed:
  apache2-common apache2-mpm-worker apache2-utils openssl ssl-cert
Suggested packages:
  apache2-doc ca-certificates
The following NEW packages will be installed:
  apache2 apache2-common apache2-mpm-worker apache2-utils openssl ssl-cert
0 upgraded, 6 newly installed, 0 to remove and 0 not upgraded.
Need to get 2040kB of archives.
After unpacking 6218kB of additional disk space will be used.
Do you want to continue? [Y/n]

Once the server is installed you need to do three things to get a working SSL setup:

  1. Generate, or import, a certificate.
  2. Enable Apaches SSL support.
  3. Configure your SSL options.

Generating A Certificate

Generating a certificate from scratch will give you something which will be used to protect the traffic exchanged between clients and your server, however it will be unsigned by a trusted certificate authority so it will generate warnings.

Importing a paid and “trusted” certificate will avoid this problem, but that is beyond the scope of this simple introduction.

Generating an SSL certificate for Apache2 may be accomplished using the apache2-ssl-certificate script. This will ask you questions interactively then generate the certificate file appropriately.

Here’s a sample session:

earth:~# apache2-ssl-certificate

creating selfsigned certificate
replace it with one signed by a certification authority (CA)

enter your ServerName at the Common Name prompt

If you want your certificate to expire after x days call this programm
with -days x
Generating a 1024 bit RSA private key
writing new private key to '/etc/apache2/ssl/apache.pem'
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
Country Name (2 letter code) [GB]:
State or Province Name (full name) [Some-State]:Scotland
Locality Name (eg, city) []:Edinburgh
Organization Name (eg, company; recommended) []:Steve Kemp
Organizational Unit Name (eg, section) []:
server name (eg. ssl.domain.tld; required!!!) []:earth
Email Address []:

Enabling SSL Support

To use the SSL facilities of Apache2 you must enable the module mod_ssl, this can be achieved using the helper tool a2enmod (We’ve previously discussed the Apache2 helper scripts.)

As root run:

earth:~# a2enmod ssl
Module ssl installed; run /etc/init.d/apache2 force-reload to enable.

Once this is done you’ll have Apache setup to accept SSL connections, but the server will still only be listening for incoming HTTP requests on port 80 – and not SSL connections on port 443. To fix this you must add a line to the file /etc/apache2/ports.conf:

Listen 443

With these two steps out of the way you now have an Apache setup which will listen for and accept SSL connections. The next step is to modify your virtualhosts to use it.

Configuring your SSL Hosts

With a certificate setup, and the server updated to load and listen for incoming SSL connections you’re almost finished. The final step is to ensure that your virtual hosts, or main host, will accept SSL options.

I use virtual hosts upon my machine and this just means adding a couple of options to each one I wish to use SSL:

SSLEngine on
SSLCertificateFile /etc/apache2/ssl/apache.pem

For reference here is a complete example which should be easy to modify/understand:

NameVirtualHost *:443
NameVirtualHost *:80

<VirtualHost *:80>
        DocumentRoot /var/www/
        ErrorLog /var/log/apache2/error.log
        CustomLog /var/log/apache2/access.log combined

<VirtualHost *:443>

        DocumentRoot /var/www/
        ErrorLog /var/log/apache2/error.log
        CustomLog /var/log/apache2/access.log combined

        SSLEngine on
        SSLCertificateFile /etc/apache2/ssl/apache.pem

Tags: , , , , ,

Posted by

30 Apr 2007 Finding which package contains a file in Debian

There are times when you’re looking for a particular library, or file, which you know is available to Debian/Ubuntu but you cannot find the package which contains it. This is the kind of job that the Debian packages site helped with in the past, but given its current unavailability we’ll look at another approach. (more…)

Tags: , , , ,

Posted by

30 Apr 2007 Install Automatix2 on Debian Etch with apt

Automatix2 is a graphical interface (written in python and bash) for automating the installation of the most commonly requested applications in some Debian based distributions. (more…)

Tags: , ,

Posted by

27 Apr 2007 Howto duplicate a Debian setup

This post describes howto reinstall or duplicate a Debian or Debian based distribution like Ubuntu.
First we need to extract the installed packages on the source server and save them in a file

debian:~# dpkg --get-selections >> packages

Now we move to the target server and set the package selections according to the package file we just created on the source machine.

debian:~# dpkg --set-selections < < packages

Now we just need to run this in order to actually install the packages.

debian:~# apt-get -u dselect-upgrade

Tags: , ,

Posted by