Kmail does not ask for PGP password

A few days ago I fucked up my Debian installation. It ran properly for several years but because of mixing different repositories (squeeze, wheezy, backports,…) aptitude somehow lost track about packet versions. I spent several hours but was unable to fix it. It just got worse.

Thus, I decided to do a completely fresh installation of Debian/Wheezy. I always do a basic installation first without X11 desktop. If everything works then I add X11 and KDE being my favorite.

Of course I kept my home directory as usual to keep all settings, all emails, and all other stuff that hangs around in this directory.

Most things worked immediately but kmail did not ask for the password of my PGP key anymore, when trying to sign emails. I check its settings and everything looked fine. I also checked kgpg which continued to successfully sign/encrypt messages.

I found the following bug report which also contains some links:

In my new installtion the gpg-agent is installed by default and it is running as can be simply verified. I then check for pinentry and I found out that pinentry-gtk2 was installed but pinentry-qt4 not. I don’t know if this is by intention or if there is a wrong dependency somewhere. I think the latter is the case because I installed KDE which is Qt-based but I did not install Gnome (which is GTK-based).

I simply installed pinentry-qt4 but kmail still did not ask for the password (just “signing error: illegal passphrase”). I looked at gpg-agent in more detail and found out that it creates an environment file in my ~/.gnupg directory. When looking into this directory I remembered that I had a similar problem several years ago. Therein is the configuration file gpg-agent.conf which is loaded by gpg-agent at startup. It contained the following line:

pinentry-program /usr/bin/pinentry-qt

I now tried to start pinentry-qt manually but the binary didn’t exist although I had installed the package. Apparently the binary was renamed to pinentry-qt4. I changed the corresponding line in gpg-agent.conf, restartet gpg-agent and the problem was solved.