Red Hat s Matthew Garrett let the cat out of the bag about a month ago: when UEFI Secure Boot is adopted by mainboard manufacturers to satisfy Microsoft Windows 8 requirements, it may very well be the case that Linux and others (BSD, Haiku, Minix, OS/2, etc) will no longer boot.
Matthew has written about it extensively and seems to know very well what the issues are (part I, part II), the details about signing binaries and why Linux does not support Secure Boot yet.
The Free Software Foundation has also released a statement and started a campaign, which is, as usually, anti-Microsoft instead of pro-solutions.
Now let me express my opinion on this matter: this is not Microsoft s fault.
Facts
Let s see what are the facts in this controversy:
I received recently a mail about my attempt to provide Grsecurity kernels in Debian. The
sender found the bug by accident, and asked me why I didn't do some
more publicity here. So here we are.
I won't go into details on what grsecurity is, it's fairly
complex. But it's basically a hardening patch for the Linux kernel,
with three main components:
deb http://molly.corsac.net/~corsac/debian/kernel-grsec/packages/ sid/ The repository is signed by my key which you can add to your apt setup using apt-key add. If you want to rebuild the packages yourself, here's the method:
mkdir kernel-grsec
cd kernel-grsec
svn checkout
svn://svn.debian.org/svn/kernel/dists/sid/linux-2.6
git clone
git://anonscm.debian.org/users/corsac/grsec-patches.git
wget
http://www.kernel.org/pub/linux/kernel/v3.0/linux-3.0.tar.bz2
wget
http://www.kernel.org/pub/linux/kernel/v3.0/linux-3.0.tar.bz2.sign
gpg --verify linux-3.0.tar.bz2
cd linux-2.6
apt-get build-dep linux-2.6
export QUILT_PATCHES=../grsec-patches
quilt push -a
python debian/bin/genorig.py ../linux-3.0.tar.bz2
debian/rules orig
fakeroot debian/rules source
fakeroot make -f debian/rules.gen binary-arch_amd64_grsec_amd64
You could also do dpkg-buildpackage, pdebuild or whatever.
Kernel
handbook is a nice reading too if you want more information on
how to rebuild Debian kernels. The quilt push -a may fail if you
checkout an svn version more recent than mine. I try to keep
patches up to date but I usually have some delay.
Note that installing the kernel will require installing
linux-grsec-base package. Binary is not yet available on my mirror
but you can easily build it. Source can be found on
git.debian.org.
If you're interested by this, don't hesitate to mail me or the
bug.
This post is made in a personal capacity. While it represents the outcome of multiple discussions on the topic with a variety of people, nothing written below should be construed as Red Hat's corporate position
Rapha l Hertzog recently announced
a new dpkg-buildflags interface in dpkg that at long last gives the
distribution, the package maintainers, and users the control they want over
the build flags used when building packages.
The announcement mail gives all the gory details about how to invoke
dpkg-buildflags in your build to be compliant; but the nice thing is, if
you're using dh(1) with debian/compat=9, debhelper does it for you
automatically so long as you're using a build system that it knows how to
pass compiler flags to.
So for the first time, /usr/share/doc/debhelper/examples/rules.tiny can now
be used as-is to provide a policy-compliant package by default (setting
-g -O2 or -g -O0 for your build regardless of how debian/rules is
invoked).
Of course, none of my packages actually work that way; among other things I
have a habit of liberally sprinkling DEB_MAINT_CFLAGS_APPEND := -Wall
in my rules, and sometimes DEB_LDFLAGS_MAINT_APPEND := -Wl,-z,defs and
DEB_CFLAGS_MAINT_APPEND := $(shell getconf LFS_CFLAGS) as well. And my
upstreams' build systems rarely work 100% out of the box with dhauto*
without one override or another somewhere. So in practice, the shortest
debian/rules file in any of my packages seems to be 13 lines currently.
But that's 13 lines of almost 100% signal, unlike the bad old days of
cut'n'pasted dh_* command lists.
The biggest benefit, though, isn't in making it shorter to write a rules
file with the old, standard build options. The biggest benefit is that
dpkg-buildflags now also outputs build-hardening compiler and linker flags
by default on Debian. Specifically, using the new interface lets you pick up
all of these hardening flags for free:
-fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -Wl,-z,relro
It also lets you get -fPIE and -Wl,-z,now by adding this one line to
your debian/rules (assuming you're using dh(1) and compat 9):
export DEB_BUILD_MAINT_OPTIONS := hardening=+pie,+bindnow
Converting all my packages to use dh(1) has always been a long-term goal,
but some packages are easier to convert than others. This was the tipping
point for me, though. Even though debhelper compat level 9 isn't yet frozen,
meaning there might still be other behavior changes to it that will make more
work for me between now and release, over the past couple of weekends I've
been systematically converting all my packages to use it with dh. In
particular, pam and samba have been rebuilt to use the default hardening
flags, and openldap uses these flags plus PIE support. (Samba already
builds with PIE by default courtesy of upstream.)
You can't really make samba and openldap out on
the graph, but they're
there (with their rules files reduced by 50% or more).
I cannot overstate the significance of proactive hardening. There have been
a number of vulnerabilities over the past few years that have been thwarted
on Ubuntu because Ubuntu is using -fstack-protector by default. Debian has
a great security team that responds quickly to these issues as soon as
they're revealed, but we don't always get to find out about them before
they're already being exploited in the wild. In this respect, Debian has
lagged behind other distros.
With dpkg-buildflags, we now have the tools to correct this. It's just a
matter of getting packages to use the new interfaces. If you're a maintainer
of a security sensitive package (such as a network-facing daemon or a setuid
application), please enable dpkg-buildflags in your package for wheezy!
(Preferably with PIE as well.) And if you don't maintain security sensitive
packages, you can still help out with the hardening release
goal.
A month ago I started a new job, at Codethink,
a British software development company. We work mainly on and with free
software. I'm working on a new project called
Baserock, a way to
build embedded Linux systems that we think will avoid many of the
pain points that people usually have. Baserock is still in its formative
stages, not something you can really play with.
Codethink has its main office in Manchester, so the past weekend I moved
there with my fianc .
Oh yeah, Soile and I got engaged. Rings of Palladium.
While I've been having a lot of fun, I'd like to be bored for a while now.
Instead, I'm going to Prague for ELC Europe.
I am currently running a crowdfunding campaign whose ultimate goal is to liberate the English translation of a French book that I have written. This book will be named The Debian Administrator s Handbook because it has primarily been written for Debian.
Creating a new Ubuntu book based on The Debian Administrator s Handbook
But since Ubuntu is based on Debian, a large part of its content applies equally well to Ubuntu. While discussing with Mark Shuttleworth, he suggested me to reuse those parts and to create a new book dedicated to Ubuntu. It would also cover the latest cloud technologies that Ubuntu has been delivering (since this is a topic that the current book does not cover).
This is something that I have been envisioning for a while and something that I would be ready to try if we manage to complete the liberation of the current book. This project would then bring a truly free book to the Ubuntu ecosystem.
Why? The official Ubuntu books are not really free
There s a policy in place that ensures that official Ubuntu books use a free software/culture license and they are effectively available under the terms of a Creative Commons Share Alike license. But try to create a derivative book you won t find the sources (LaTeX or DocBook usually with most big books). You can only find a few PDF copies if you google for it. But this is really not the preferred form of modification for such a book.
Those books are also not packaged. Ubuntu much like Debian deserves to have a good book embodying the values of free software that can be shipped together with its product.
When I speak of liberation of the book, I really mean it in the way that free software hackers are used to: a public Git repository containing the DocBook sources, the pictures and the .dia files for the various schemas.
Help Ubuntu by spreading the word
I understand that at this point this proposed Ubuntu book is really hypothetical ( vaporware one could say) but we need to go step by step to make it a reality. And the first step is to ensure that we manage to liberate the Debian Administrator s Handbook.
For this I am seeking the support of the Ubuntu community to promote the current fundraising campaign. If the perspective of the Ubuntu book is not enough to convince you, you ll be glad to learn that I also commit to give back to Ubuntu 15% of the money raised via the link below (once VAT has been subtracted).
Click here to go to the crowdfunding campaign page and pledge a few euros. Then share this article (or the link http://debian-handbook.info/go/ulule-ubuntu/) and convince others to participate.
At this point, the liberation target is entirely reachable with your help and the help of the community: the remaining 18 K needed in the liberation fund represent 720 persons giving 25 EUR each or 1800 persons giving 10 EUR each.
Thank you very much for your support and your help in this project!
One comment Liked this article? Click here. My blog is Flattr-enabled.
A couple of times I have written code which basically does this:
my $chain = IO::Splice->new($fh1, $fh2);
$chain->pump(); # read and write from both handles if possible and needed
$chain->read($fh1); # read to buffer from one specific handle
$chain->write($fh2); # write from buffer to one specific handle
$chain->can_write(); # returns the handles it needs to write to
but it might be simpler to have two callbacks for setting a file handle in write or no-write state:
my $readset = IO::Select->new( $fh1, $fh2);
my $writeset = IO::Select->new();
my $chain = IO::Splice->new( $fh1, $fh2,
writable => sub $writeset->add( shift ) ,
unwritable => sub $writeset->remove( shift )
);
while ( ... select ... )
$chain->pump();
As said, I think I have plenty of implementations of the na ve way but before releasing some code it would be nice to get some input on the API. But the best feedback would be a module that already have a usable API but might not implement the Linux specific way. That would allow me to steal the interface
The few articles I wrote that explained how to install GNOME 3 from Debian experimental have been very popular. So I figured out that a small update would be welcome.
The Debian GNOME team started uploading a mix of GNOME 3.0 and 3.2 packages to Debian unstable because the release team is ready to take care of this transition. This means that as soon as the packages are ready in Debian unstable, the release team will ensure that they also reach wheezy (aka the current testing distribution).
So if you re a Debian unstable/testing user with a GNOME Desktop, expect some important changes by the way my experience with GNOME 3 was recently plagued by some rendering issues resulting in parts of the screen not being properly refreshed. While trying to track this down (and investigating clutter as a possible culprit) I came upon this mail on the clutter-devel mailing list. I recompiled mutter with the indicated patch and it fixed my issue. I immediately uploaded mutter 3.0.2.1-4 with the fix so this issue should be gone for the many people who are going to experience GNOME 3 for the first time in the coming days.
It s also worth noting that contrary to how upstream handles it (they hide the fallback mode and the user has to enable an option to use it in place of the GNOME Shell), Debian has a dedicated session for the GNOME 3 fallback mode so you decide what you get right from the login screen. This will be appreciated by the people who do not see GNOME 3 as a step in the right direction. Unless they switch to XFCE as some did.
As far I am concerned, I m already used to GNOME 3. I spend most of my time in terminals, browsers and an IRC application and the whole Shell does not fundamentally changes my work habits.
21 comments Liked this article? Click here. My blog is Flattr-enabled.
Good morning all!
It feels like forever since I last blogged . Which is extremely bad of me *slaps own wrist*. However, I m been horrendously stupidly busy. As some of you may know, I m very much an Android fan. Recently, I ve gotten myself a shiny Galaxy SII.
Given the fact that alongside my day job of being a Web Developer for an Online Retailer, I m also a Voluntary Ambulance Person I thought it d be useful to ask my current workplace if they d provide me a mobile phone cover for my new phone. Of course, work were more than happy to provide me with a shiny Samsung Galaxy S2 case (I actually went for the Case-Mate Barely There in brushed aluminium).
Being a voluntary Ambulance Person, I regularly have to go to random places to pick up an ambulance/attend an event. Because of that I rely quite heavily on Google Maps and it s navigation features (Free Sat Nav in my opinion, the killer feature of Android).
Having only had my phone a week, I started to find that there were a few problems with the GPS. Whereas previously, I d been able to lock on almost instantly, It d now take me about half an hour (literally) to get a lock on anything. I tried Googling, I tried everything I could think of, but to no avail. I downloaded GPS Test, and it was showing that while it was picking up a couple of sattelites, it wasn t picking up enough to get a decent lock
The image above is a screenshot of the GPS test from directly outside my front door, taken after it had settled down.
As you can imagine, I wasn t happy and was ready to send the phone back.
Then, for some reason, a brainwave hit me (It doesn t happen often). What changed from when it was working to now? I know! The Case
*takes case off, tries GPS test again*
It can be amazing what happens when you realise that shiny case you have is mainly made of aluminium. Guess what works well at deflecting radio signals and the like You got it, aluminium.
So now I need to decide whether to get another case or whether to just take the case off when I need to do sensible things.
Other than the case problem, I m finding that the Samsung Galaxy SII is a great phone (as soon as I got rid of Touchwiz). I m not a fan of the OEM Samsung crap that s been bolted onto the phone, and will, as soon as there s a decent release, be putting a copy of CyanogenMod on the phone (I ve already made most of the tweaks I just want rid of SNS)
In other news I ve started more and more gaming again. If you re interested in a couple of rounds of TF2 or some SC2 (or some Portal 2 Co-Op) then give me a shout with your Steam ID / Battle.net ID and I ll see what I can do. I m thinking of starting doing some Let s Play Videos, as my Youtube Channel is looking a bit sparse!
I m going to try and start blogging a bit more aswell so if there s anything you want to see me blog about pop a post in the comments below!
Till next time..
Jean-Yves Lefort s link-monitor-applet, an applet for the GNOME panel, is a great tool for those with often-changing and possibly unreliable network connection. It allows me to see, at one glance, whether I can reach the router, the internet and/or my VPN. Furthermore, the latency display tells me whether there is a point in working over SSH right now. I often observe other people, e.g. on conferences, to stare for a while at a non-loading web page, then fire up a terminal window and run random ping commands, while I immediately see that the network is down and can relax.

The issue
This morning (while I was running late for an appointement) I
had a very weird stuff happening on my Thinkpad T61 laptop. Since I
recently offered myself a shiny Thinkpad x201s, I have to admit I
don't use much my T61 anymore. But this morning I had to print a
page (for this appointement) and, as I didn't yet configured my
printer on the x201s, I went to the T61. But I noticed that the
network was down. I've tried quickly on wireless but, bad luck, my
current wifi setup selects the channel automatically and it prefers
choosing channels which aren't available in the US. Guess what, my
T61 comes from the US and has those channels completely disabled,
so no wireless available either.
The investigation
I first tried to
modprobe -r e1000e
modprobe e1000e
to see if it fixed the problem, but it didn't. Worse, the
interface disappeared and never reappeared. I tried to reboot but
it didn't fix the problem, the link was still down. Running really
late, I put the file on a usb key and printed it from the powerbook
and postponed the fix for later.
Now, this evening, I tried to investigate a bit more. Symptoms
weren't only that the nic wasn't working, but there was a high load
on the system (1-2 at idle), unresponsiveness every second or so,
and watching top I could see spikes of high cpu usage for the
kworker kernel thread. Typing that on google you can find a lot of
people running on this issue, usually starting around kernel 2.6.36
or 2.6.37. Now, I might have upgraded the kernel recently to
3.0.0-4, but that didn't look related since the problem first
appeared when the laptop was up and running. And I tried to reboot
under 2.6.39, 2.6.38 and even 2.6.32 and the problem was still
present. Each time, unloading the module would fix the problem, but
loading it again wouldn't make the interface reappear. People
advised to boot with pcie_ports=compat but that didn't do anything.
I tried to boot without intel_iommu=force (disable Intel Vt-d) and
pcie_aspm (Active State Power Management) but nothing either.
Considering a userland issue, I've tried to boot a grml live distro (always keep a grml.iso in
your /boot, extlinux-update will even put it in your menu
automatically), and the problem was still present. So not a Debian
kernel issue, not a userland issue, only thing left was the laptop.
I didn't update the Bios recently, so I wondered exactly what could
be the problem. I started to feel a little bad, since I still
really like that laptop, and that I already decided to lend it to
my sister since her own T61 is sitting with a dead system board in
my shelf. I know she might have some negative waves, but she was
not even landed when the problem first appear.
The fix
Then I had a flash. It's not mystery that I'm used to break network
cards, and I had the bright idea to shutdown the laptop,
disconnect AC and battery, then let it idle a bit. I even tried the
secret Thinkpad power button code but I think it's unrelated.
Then I re-plugged the battery, booted to grml and the issue was
gone. I rebooted on the standard Debian and the link was up,
network was working.
So what happenned?
The (tentative) explanation
My guess is that, somehow, the network card firmware has an
issue and choked on something (a network frame or an attack exactly
like the one we demonstrated on ASF firmware). In fact, no, I don't
think it's the e1000e firmware. My T61 comes with Intel vPro, which
includes AMT (Active Management Technology), a remote management
solution a bit like ASF but more advanced. As far as I know, AMT
firmware always runs, even when it's disabled, it's just completely
idle. Idle, but in this case I think it choked on something, and a
reboot isn't enough to restart the AMT firmware. But a real hard
reset without any power seems to do the trick.
What next?
Well, a part of me is pretty scared, but another is just bored.
I mean, we know about that, that's exactly the kind of issue we are
warning people of. I have no idea what exactly happened, and
there's no way I'll be able to reproduce that, but I'm pretty sure
it's something lying at a pretty low level in the platform, and
which can severely disable your workstation. Now if it happens
again I won't lose too much time on this.
TL;DR: helping other people
In case you came here because you searched on google terms like
kworker cpu usage , e1000e, interrupts, it might be a good idea to
first reboot on a live CD to eliminate installation issues, then
shutdown the laptop, remove the battery and let it few seconds
idle. This might be enough to reset something inside and fix the
situation.
Dear Lazyweb .
I ran into a very strange issue with MySQL authentication. The initial situation is as follows:
sven@a0 ~ > mysql -u sven -ptestpass -h a0.my.do.main
ERROR 1045 (28000): Access denied for user 'sven'@'a0.my.do.main' (using password: YES)
sven@a0 ~ > mysql -u sven -ptestpass -h a1.my.do.main
ERROR 1045 (28000): Access denied for user 'sven'@'a0.my.do.main' (using password: YES)
sven@a1 ~ > mysql -u sven -ptestpass -h a0.my.do.main
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 32
Server version: 5.0.77-log Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> Bye
sven@a1 ~ > mysql -u sven -ptestpass -h a1.my.do.main
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 24
Server version: 5.0.77-log Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>
All packages on both machines are up to date (CentOS5 with all updates available). The server variables shown with show variables also seem identical (except for the hostname and the server id). Besides, it looks more like a client problem to me than a server problem.
Last datapoint: If I define the mysql user sven with an explicit host (a0.my.do.main and a1.my.do.main) instead of a wildcard, everything works nicely, from and to both hosts.
So, dear lazyweb: Does anyone have an idea what might be causing this issue?
Update:
Due to some comments, let me add a few points of information:
No, my blog isn't dead, and neither is me. It's just that way too many things happened since this year's debconf that got me a bit off tracks. I managed to do daily business like keeping my packages in shape and the backports queue low, and that was mostly it.
No clue if that will change anytime soon, but I guess I would like to keep you updated with an event where you can meet me next week: There will be the Global 2000 Birthday Party going on in the WUK on Thursday 20th, so if you happen to be in Vienna at that time, drop by and enjoy some great bands.
... which brings me to one of the local bands from Vienna: Heinz aus Wien. They are around for well over 10 years now and are still rocking quite well. Here are some examples of their songs, like always:
Poor Sarah. Cat dramas always
seem to befall us when she's in Australia.
It looks as if Smudge has managed to escape the house. Being at work all
day, it took me 24 hours to notice.
Our friend Helen came over on Sunday night. Smudge was definitely around
then, because she was climbing all over Liam. Helen used the downstairs
bathroom before she went home, and I remember her having to shoo Smudge
out because she was in there. I'm pretty sure she went home after that. If
my memory serves, she saw herself out and I was in the kitchen cleaning up,
so my current theory is that she escaped when Helen left.
On Monday night, I had a lengthy video call with Sarah, who was at my
parent's place setting up their new Mac Mini. I didn't realise until after
that, when I was about to go to bed, that I hadn't been harassed by Smudge
all evening. So I searched the house that night, and couldn't find her.
Liam had already gone to bed for the night, so I hoped she was stuck in his
room, and went to bed too.
This morning, Liam and I both searched the house, and the immediate
surrounds, without any luck. I called the Palo Alto Animal Services (I got
the dispatch because the shelter hadn't opened yet), emailed
the local neighbourhood
association, and went to work.
I called Palo Alto Animal Services again later in the day to report her
missing to the shelter itself, and Betty-Ann there recognised my accent and
name and asked me if I was Sarah's husband (Sarah used to volunteer there a
lot, and we adopted Smudge from there), so they're now keeping a look out.
Smudge is micro chipped, but wasn't wearing a collar. She's allowed in the
back yard, because it's totally enclosed and can't escape, so she shouldn't
be totally freaked out by being outdoors. Whenever she does escape out the
front door, she usually makes a beeline to the right, which is mostly
enclosed, but she can certainly get out of the complex. Unfortunately she
often doesn't come when called, so for all I know she's in some obscure
location 10 metres from the front door and I can't see her.
My main concerns are that we're only two blocks from Highway 101, so if she
does stray too far, she could get into serious trouble, and I'm also a bit
worried about raccoons giving her grief.
I spent some time tonight putting up posters in the immediate area and
poking around bushes. I've left the two humane cat traps that we have out by
the front door with some cat food in them, in the hope that she's roaming
around and will walk into one of them.
Oh and the other big concern I have is that Halloween is coming up.
Shelters tend not to adopt out black cats around Halloween because bad
things can happen to them.
So now we wait. I'm really hoping she turns up safe and sound, soon.

# apt-get install pcscd gnupg-agent gpgsmThe above command should install and start
pcscd and if all works well, you should be able to check the status of the smartcard using GnuPG.
# gpg --card-statusYou need to initialize the smartcard and generate a private key on it, again using GnuPG. If you trust GnuPG more than the smartcard to generate a good private key, you may generate the private key using GnuPG and then move it onto the smartcard (hint: use the
keytocard command). Make sure you don t leave a copy of the private key on the same machine!
# gpg --card-edit
gpg: detected reader Gemalto GemPC Key 00 00'
...
gpg/card> admin
Admin commands are allowed
gpg/card> name
Cardholder's surname:
Cardholder's given name: host.example.org
gpg: 3 Admin PIN attempts remaining before card is permanently locked
Please enter the Admin PIN
gpg: gpg-agent is not available in this session
gpg/card> lang
Language preferences: en
gpg/card> generate
Make off-card backup of encryption key? (Y/n) n
Please enter the PIN
What keysize do you want for the Signature key? (2048)
What keysize do you want for the Encryption key? (2048)
What keysize do you want for the Authentication key? (2048)
Please specify how long the key should be valid.
0 = key does not expire
<n> = key expires in n days
<n>w = key expires in n weeks
<n>m = key expires in n months
<n>y = key expires in n years
Key is valid for? (0)
Key does not expire at all
Is this correct? (y/N) y
You need a user ID to identify your key; the software constructs the user ID
from the Real Name, Comment and Email Address in this form:
"Heinrich Heine (Der Dichter) <heinrichh@duesseldorf.de>"
Real name: host.example.org
Email address:
Comment:
You selected this USER-ID:
"host.example.org"
Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? o
gpg: existing key will be replaced
gpg: please wait while key is being generated ...
gpg: key generation completed (33 seconds)
gpg: signatures created so far: 0
gpg: existing key will be replaced
gpg: please wait while key is being generated ...
gpg: key generation completed (18 seconds)
gpg: signatures created so far: 1
gpg: signatures created so far: 2
gpg: existing key will be replaced
gpg: please wait while key is being generated ...
gpg: key generation completed (23 seconds)
gpg: signatures created so far: 3
gpg: signatures created so far: 4
gpg: key 12345678 marked as ultimately trusted
public and secret key created and signed.
gpg: checking the trustdb
gpg: 3 marginal(s) needed, 1 complete(s) needed, PGP trust model
gpg: depth: 0 valid: 1 signed: 0 trust: 0-, 0q, 0n, 0m, 0f, 1u
pub 2048R/12345678 2011-09-19
Key fingerprint = 1234 5678 1234 5678 1234 5678 1234 5678 1234 5678
uid host.example.org
sub 2048R/23456789 2011-09-19
sub 2048R/34567890 2011-09-19
gpg/card> quit
#
Now for the interesting part. OpenSSH talks to an agent for private key handling, and GnuPG s gpg-agent supports this protocol when the --enable-ssh-support parameter is given. During startup, gpg-agent will print some environment variables that needs to be set when ssh is run. Normally gpg-agent is invoked by the Xsession.d login scripts, so that the environment variables are inherited by all your processes. However, for an unattended machine without any normal login process, we need to write a script to start gpg-agent. First do these manual steps, to confirm that everything works.
# gpg-agent --daemon --enable-ssh-support > /var/run/gpg-agent-info.env # . /var/run/gpg-agent-info.env # ssh-add -L ssh-rsa AAAAB3N... cardno:000500000BD8 #If the final step printed a SSH public id, the (sometimes) tricky part in getting the hardware to work is (hopefully) complete. What remains is to script things so that
gpg-agent is started on boot and to make sure that your backup scripts has the proper environment variables before launching whatever processes will launch ssh. Further, since we will be running unattended, we need a mechanism to unlock the smartcard using a PIN interactively once on each boot of the machine. I prefer manually entering the PIN on every boot over having the PIN stored in a file on the disk.
I will use the /etc/rc.local mechanism to start gpg-agent, like this:
# cat> /etc/rc.local
#!/bin/sh -e
exec gpg-agent --daemon --enable-ssh-support \
--pinentry-program /usr/local/sbin/pinentry-unattended \
--write-env-file /var/run/gpg-agent-info.env
^D
The astute reader will now ask what /usr/local/sbin/pinentry-unattended is and why it is needed. Now here is the situation. scdaemon will normally query the user for a PIN using a tool called pinentry which reads and write to the user s TTY directly. This won t work in unattended mode, so we want the scdaemon to signal failure here unless we are actually unlocking the smartcard manually. Here is the entire script:
#!/bin/sh
# /usr/local/sbin/pinentry-unattended -- by Simon Josefsson
if test x"$PINENTRY_USER_DATA" = xinteractive; then
exec pinentry "$@"
fi
exit 1
What remains is a script to unlock the smartcard by providing the PIN. This is typically invoked manually if the server has restarted for some reason. Don t worry, any ssh sessions invoked by cron until you have managed to unlock the smartcard will fail with an authentication error it won t hang waiting for a PIN to be entered.
#!/bin/sh
# /usr/local/sbin/unlock-smartcard -- by Simon Josefsson.
. /var/run/gpg-agent-info.env; export GPG_AGENT_INFO SSH_AUTH_SOCK SSH_AGENT_PID
gpg-connect-agent 'scd killscd' /bye > /dev/null
while ! gpg-connect-agent 'scd serialno' /bye grep -q SERIALNO; do
sleep 1
done
PINENTRY_USER_DATA=interactive
export PINENTRY_USER_DATA
checkpin
And the script checkpin is as follows:
#!/bin/sh # /usr/local/sbin/checkpin -- by Simon Josefsson. id= gpg-connect-agent 'scd serialno' /bye head -1 cut -d\ -f3 gpg-connect-agent "scd checkpin $id" /bye grep -q OKAt this point, you should have everything configured and installed. Don t forget to
chmod +x the scripts. The typical use-pattern is as follows. After the machine has been started, gpg-agent is running but the smartcard is not unlocked with the PIN. You need to manually login to the machine and run unlock-smartcard and enter the PIN. In the script that runs the backup jobs, invoked via cron, make sure that the first line of the scripts reads (assuming Bourne shell script syntax):
. /var/run/gpg-agent-info.env; export GPG_AGENT_INFO SSH_AUTH_SOCK SSH_AGENT_PIDTo avoid needlessly attempting ssh connections if the smartcard is not unlocked, your backup script can also call the
checkpin code and abort if it doesn t return true.
checkpin exit 1Some final words about debugging. A basic command to run to check that the GnuPG side is working is
gpg --card-status, it should print some information about the smartcard if successful. To check that the SSH agent part is working, use ssh-add -L. If you get error messages, try killing the scdaemon process by running killall -9 scdaemon and let gpg-agent respawn a new scdaemon process.
That s it! If you like my writeup, please flattr it.
I was expecting to write more about the 7th Rugby World Cup, but real
life, Debian work and running activities prevented me to do so..
Still, I watched several games and I can share my feelings now.
First of all, this is a tremendous organization from New Zealand. It
seems that about the entire country is working on making this even a
great success and I really appreciate to see a place I certainly have
to visit some day receiving such wordlwide attention (OK, admitedly,
mostly in the part of the world that understands rugby).
First round already gave several surprises even if the 1/4 finals were
after all kinda expected (at least, the list of countries).
Next.