#!/bin/blog

December 31, 2008

Using the SSH agent from daemon processes

Filed under: UNIX & Linux — Tags: , , , — martin @ 1:04 am

One of my more recent installations, the BackupPC server I wrote about earlier, needs full access as the user root to his clients in order to retrieve the backups. Here’s how I implemented authentication on this machine.

BackupPC runs as its own designated user, backuppc. All authentication procedures therefore happen in the context of this user.

The key component in ssh-agent operation is a Unix domain socket that the ssh client uses to communicate with the agent. The default naming scheme for this socket is /tmp/ssh-XXXXXXXXXX/agent.<ppid>. The name of the socket is stored in the environment variable SSH_AUTH_SOCK. The windowing environments on our local workstations usually run as child processes of ssh-agent. They inherit this environment variable from their parent process (the agent) and therefore the shells running inside our Xterms know how to communicate with it.

In the case of a background server using the agent, however, things are happening in parallel: On one hand, we have the daemon which is being started on bootup. On the other hand, we have the user which the daemon is running as, who needs to interactively add his SSH identity to the agent. Therefore, the concept of an automatically generated socket path is not applicable and it would be preferable to harmonize everything to a common path, such as ~/.ssh/agent.socket.

Fortunately, all components in the SSH authentication system allow for this kind of harmonization.

The option -a to the SSH agent allows us to set the path for the UNIX domain socket. This is what this small script, /usr/local/bin/ssh-agent-wrapper.sh does on my backup server:

#!/bin/bash
SOCKET=~/.ssh/agent.socket
ENV=~/.ssh/agent.env
ssh-agent -a $SOCKET > $ENV

When being started in stand-alone mode (without a child process that it should control), ssh-agent outputs some information that can be sourced from other scripts:

SSH_AUTH_SOCK=/var/lib/backuppc/.ssh/agent.socket; export SSH_AUTH_SOCK;
SSH_AGENT_PID=1234; export SSH_AGENT_PID;
echo Agent pid 1234;

This file may sourced from the daemon user’s ~/.bash_profile:

test -s .ssh/agent.env && . .ssh/agent.env

However, this creates a condition where we can’t bootstrap the whole process for the first time. So it might be somewhat cleaner to just set SSH_AUTH_SOCK to a fixed value:

export SSH_AUTH_SOCK=~/.ssh/agent.socket

Here’s the workflow for initializing the SSH agent for my backuppc user after bootup:

root@foo:~ # su - backuppc
backuppc@foo:~ $ ssh-agent-wrapper.sh
backuppc@foo:~ $ ssh-add

In the meantime, what is happening to the backuppc daemon?

In /etc/init.d/backuppc, I have added the following line somewhere near the top of the script:

export SSH_AUTH_SOCK=~backuppc/.ssh/agent.socket

This means that immediately after boot-up, the daemon will be unable to log on to other systems, as long as ssh-agent has not been initialized using ssh-agent-wrapper.sh. After starting ssh-agent and adding the identity, the daemon will be able to authenticate. This also means that tasks in the daemon that do not rely on SSH access (in the case of BackupPC, things like housekeeping and smbclient backups of “Windows” systems) will already be in full operation.

December 27, 2008

Liebe Automobilhersteller

Filed under: Internet — martin @ 2:28 pm

Könnt ihr mir mal verraten, wie ich in Muße eure Meisterleistungen der Ingenieurskunst im “Konfigurator” zusammenbasteln soll, wenn unterdessen mein Rechner die Triebwerke startet, um die Abwärme eurer beschränkten Flash-Videos abzutransportieren? Das ist doch vollkommen albern.

Konditionierung durch Wirtschaftskrise

Filed under: Politics — Tags: , , — martin @ 2:17 pm

Der Einzel- und Versandhandel hat angeblich das beste Weihnachtsgeschäft aller Zeiten (mindestens) hinter sich gebracht. Ich kann mich da aus dem mageren Wintern zu Anfang des Jahrzehnts auch noch an andere Nachrichten erinnern.

In der Zeitung ist trotzdem in jedem zweiten Artikel von Krise und Rezession die Rede. Mich erinnert das auf unerfreuliche Weise an 02 und 05. In 02 waren wir nämlich zum zweiten mal nach 98 ungezogen gewesen und hatten den (im nachhinein wirklich unsäglichen) Schröder ein zweites mal zum Kanzler gewählt gehabt. Woraufhin das Land von einer oh wie schrecklichen Krise geplagt wurde.

Nach der Neuwahl in 05 kam dann endlich die Merkel dran und alles wurde wie durch Geisterhand gut. Eben bis jetzt. Jetzt wird uns nämlich vorsorglich schonmal klargemacht, was für eine Nulpe der SPD-Finanzminister ist und wieviel besser wir es in einem rabenschwarzen Deutschland haben könnten.

Ein paar Banken haben sich in ihrer Gier verzockt und sind dabei leider nicht pleite gegangen. Eigentlich noch viel zu gut gelaufen für die Banken. Ende der Geschichte. Wie wenig Mitleid und Aufregung hier angebracht sind, sieht man an diesem greisen Pharmaspekulanten, der sich als allerletzter noch irgendwie am großen “Börsencrash” bereichern wollte und verdienterweise eine Milliarde Euro in den Sand gesetzt hat. Lead, follow, or get the fsck out of the way, alter Mann! (Am Rande bemerkt: Für eine Milliarde muß ich so lange arbeiten gehen, bis die Sonne sich in einen faustgroßen schwarzen Kohleklumpen verwandelt hat.)

Krisen und Rezessionen sind reine Produkte des Großkapitals und seiner willigen Helfer von der gleichgeschalteten Presse, die uns klarmachen wollen, für welche politische Partei wir bei der nächsten Bundestagswahl unsere Kreuzchen zu setzen haben. Selbst wenn die Sparquote in unserer Volkswirtschaft auf Null fiele und alles verdiente Geld wieder in den Wirtschaftskreislauf zurückgepumpt würde, gäbe es für diese sauberen Herrschaften immer noch weitere Steuererleichterungen oder arbeitnehmerfeindlichere Gesetze zu erpressen.

December 26, 2008

Mitglied werden?

Filed under: Politics — Tags: , , , , , , — martin @ 7:48 am

Wenn man als stinkreicher IT-Schnösel 4000 Euro im Monat netto hat, sind die Monatsbeiträge bei politischen Parteien schon ein beträchtlich teurer Spaß:

CDU: €35 – €50 (PDF: Lt. Tabelle in der Gruppe von €3500 – €5100)
FDP: €18 (Lt. Tabelle in der Gruppe von €3601 – € 4600)
Grüne: €40 (1% vom Nettoeinkommen)
Linke: €65 (Lt. Tabelle mit Frau und zwei Kindern)
Piraten: €76 (€36 zzgl. freiwillig 1% vom Nettoeinkommen)
SPD: €135 – €245 (Lt. Tabelle in der Gruppe von €3000 – €4100)

Die Linke ruft über €2500 Nettoeinkommen eigentlich 4% auf, erlaubt aber die Herabstufung um jeweils eine Tabellenstufe pro unterhaltspflichtigem Familienmitglied. Damit landet man in der Gruppe für ein Nettoeinkommen zwischen €1900 und €2100. Die SPD erlaubt trotz ihrer gewaltigen Progression bei steigenden Gehältern keine solchen Schlupflöcher.

Die FDP kann sich nicht recht entscheiden, ob sie das Tabellenmodell durchziehen will, oder das Anteilsmodell mit 0.5% vom Nettoeinkommen. Ich habe mich daher mal für den Tabellenwert entschieden.

(Und nein: Ich verdiene keine 4000 Euro im Monat. Ich habe überhaupt kein geregeltes Einkommen. Also beruhigt euch wieder.)

December 20, 2008

I, for one, welcome our new Goo overlords!

Filed under: Games — Tags: , — martin @ 7:40 pm

The Wii keeps track of the time spent playing. Thus, it has documented today that Offspring 1.0 and I have spent no less than four hours in a row playing our new WiiWare acquistion, World Of Goo.

The gameplay of World Of Goo can be compared with the classic “Lemmings”, with a lot of physics fun added. The graphics are just the way I like them and the soundtrack is brilliant. 1500 Wii Points 15 EYPO well spent. They even have a Linux Version in the making. Yes, this is for you there in the corner, with the long hair and the black t-shirt. :-)

December 16, 2008

More BackupPC sizing considerations

Filed under: UNIX & Linux — Tags: , — martin @ 7:12 am

After the ALIX had failed, I moved my BackupPC instance to a leftover Dell workstation with 1.7 GHZ Pentium 4 and 768 GB MB of RAM.

While this is somewhat usable, the machine is badly overloaded. When multiple backup tasks are running, all RAM plus 1 GB of swap space are fully used. And the USB 2.0 disk used for storage causes the system to be waiting for I/O 70-90% of the time. On the other hand, I should probably stop the manual scheduling of backup jobs and let BackupPC do it on its own.

Nevertheless, it can be said that retrieving, compressing and indexing files surely appears to be a lot more work than just serving them. :-)

December 14, 2008

ALIX sizing lesson and WPA configuration note

Filed under: UNIX & Linux — Tags: , , , — martin @ 1:17 pm

Okay, there we have it. The ALIX, despite its generally good performance, can’t handle the workload of BackupPC and starts to swap really badly when backing up a fairly large system via rsync.

At least I’ve learned from this test how to configure the Wistron CM9 card for WPA on Debian:

iface ath0 inet static
        madwifi-base wifi0
        madwifi-mode sta
        wpa-driver wext
        wpa-ssid blah
        wpa-psk blubb
        address 192.168.1.100
        netmask 255.255.255.0
        network 192.168.1.0
        broadcast 192.168.1.255
        gateway 192.168.1.1

December 13, 2008

Hot Milfs ziehen für Dich blank

Filed under: Insanity Online — Tags: — martin @ 8:52 am

Ich fand die “Akt”-Abteilung der Fotocommunity ja schon immer ziemlich schrecklich. Ihr wißt schon: “Meine blasse Freundin mit Arschgeweih frierend auf der verregneten Waldlichtung.” Und dazu noch begeisterte Kommentare von den Betrachtern.

Anders als früher leiste ich mir heute keinen Bezahlzugang mehr und bekomme deshalb die “Akte” nur anhand der Thumbnails zu sehen, die man ungefragt präsentiert bekommt. Leider auch auf der Startseite, wo sie vermutlich auftauchen, um die Leute zum Bezahlen zu animieren.

Heute zum Beispiel:

fc-screen

Da hab ich ja schon wieder alles gesehen, was ich brauche, um mir eine Meinung zu bilden.

December 4, 2008

Fachbegriffe der professionellen IT

Filed under: Misc — Tags: — martin @ 11:01 pm

Single-Node Cluster:
“Den zweiten Knoten installieren wir dann irgendwann bei Gelegenheit.”

So gesehen und erlebt bei einem DAX-Unternehmen. Ächz!

Using a USB key for the LUKS passphrase

Filed under: Paranoia, UNIX & Linux — Tags: , , — martin @ 10:43 pm

When I had installed my notebook with Ubuntu 8.04 “Horny Hard-on”, I had opted to put the /home filesystem onto an encrypted partition on /dev/sda4. However, after a few months, entering the passphrase after turning on the computer doesn’t seem to be that attractive anymore. I have therefore decided to try to store the passphrase on a spare USB key.

This is how I migrated my LUKS container to a passphrase stored on USB media.

First, I filled the USB key with random data:
# dd if=/dev/urandom of=/dev/sdc

Then, I siphoned off 256 bytes from the USB key, to be used as the passphrase:
# dd if=/dev/sdc of=/home/martin/foo.key bs=1 count=256

foo.key is required temporarily. You may keep a copy of it stored in a safe place, or you may leave the interactive password in place as a fall-back measure. Which is what I’m doing.

The new passphrase can be added to the LUKS container like this:
# cryptsetup luksAddKey /dev/sda4 /home/martin/foo.key

Cryptsetup asks for “any passphrase”. That is one of the numerous possible passphrases that may be assigned to a LUKS device at once. Such as the interactive passphrase that is already in place.

When the new passphrase has been added, foo.key can be deleted.

Next, I determined the USB id of my USB key:
# ls -l /dev/disk/by-id/ | grep sdc
lrwxrwxrwx 1 root root 9 2008-12-04 21:31 usb-LG_XTICK_AAAAAAAAAAAAAAAAA-0:0 -> ../../sdc

I found that I needed a little helper script that extracts 256 bytes from the USB key and pipes them to stdout:

#!/bin/bash
# Script: /usr/local/sbin/dd-luks-key.sh
if [ -e $1 ]
then
dd if=$1 bs=1 count=256
fi

And now the change to /etc/crypttab:

# Old entry; ask for password:
#sda4_crypt /dev/disk/by-uuid/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee none luks
# New entry; execute the keyscript with the USB id as the argument:
sda4_crypt /dev/disk/by-uuid/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee /dev/disk/by-id/usb-LG_XTICK_AAAAAAAAAAAAAAAAA-0\:0 luks,keyscript=/usr/local/sbin/dd-luks-key.sh

That’s it. I can now reboot with the USB key plugged in and observe how the system automatically mounts the LUKS container. The USB key is not partitioned, so Gnome will not automatically mount it. It can just be pulled anytime after bootup.

If I had chosen to delete the interactive passphrase, which is stored in key slot 0:
# cryptsetup luksDelKey /dev/sda4 0

Be advised that this is no real-deal tough-minded security, but something that will protect the machine only against the type of attackers (e.g. thieves) who are out for your hardware but not for your data. Don’t leave the USB key close to the laptop. Use this responsibly. Thanks!

I’m not conviced that I will stick with this, as it’s far below my usual standard of paranoia. Nevertheless, I have gained a few nice insights into the LUKS system.

Blog at WordPress.com.