Kubuntu Breezy - Absolute beginners

Samstag, Februar 18, 2006

Get GPG Decryption working within Kmail

If you followed my last post and if you have the same problem as I did (decryption fails within Kmail, see post below), here is what I did to solve the problem:

First of all, install gnupg-agent, gnupg2 and pinentry-qt:
sudo apt-get install gnupg-agent gnupg2 pinentry-qt

Then type
sudo kate /home/username/.gnupg/gpg.conf

to open gpg.conf. Look for the line use-agent. Is it commented? If yes, remove the comment (the # sign). Save the file and close it.
End your KDE session. You can do this simply by pressing ctrl alt backspace. This will restart X completely - then login again and see if it's working. Kmail should ask for your passphrase now, and if you remember your passphrase, it will decrypt your emails.

If it's still not working, you have to write a little script which starts your gpg-agent at startup (this was the case for me).
Sounds complicated? Don't worry, it isn't! Because you can simply copy my script and it will work. Just open kate, copy the following lines and save it as gpgagent.sh

#!/bin/bash
eval "$(gpg-agent --daemon)"

#This script is in order to start gpg-agent at startup to
#have the possibility to enter your
#gpg passphrase into kmail (if gpg-agent is not
#running gpg-decryption will fail).



The first line (#!/bin/bash) tells you that this is a bash script. The next line (eval "$(gpg-agent --daemon)") is what the script really does: it starts the gpg-agent.
The last four lines with the comments (#) are the explication of what the script does.
Got the script? Ok. But now you have to save it in /home/username/.kde/env in order it is activated at startup. Maybe the folder /env doesn't exist. If this is the case, you can just create the folder:
mkdir /home/username/.kde/env
.
If you wonder why this works: startkde will check the /env folder at startup and run any .sh script which is there. Startkde tells you: "you can define environment variables that will be available to all KDE programs, so this is where you can run agents using e.g. eval `ssh-agent` or eval `gpg-agent --daemon`".

Now check if it's working. You have to logout and login again (KDE must be restarted!).
In my case Kmail finally asked for my passphrase and I was able to decrypt my mails!

If you are still having problems you may have a look at this site.

5 Comments:

  • Zerlinna!
    Yet another great one. Hope all is well with you!
    Ste-Boilerhouse.

    By Blogger boilerhouse, at 2/19/2006 02:41:00 vorm.  

  • Here everything is well! Thank you for the credits!
    I've seen your post about yakuake - really nice. I'm really addicted to yakuake ;-)

    Z.

    By Blogger Zerlinna, at 2/19/2006 02:02:00 nachm.  

  • Thanks for this hint. It worked for me as well. Why is the package pinentry needed?

    One thing i want to add is that the config file of gnupg is not called "gpg.conf" but "options" ... it contained what you mentioned tho.

    Best greetings.

    By Anonymous Anonym, at 2/20/2006 05:10:00 nachm.  

  • Kmail (since KDE 3.1) uses Ägypten to get GPG working (http://www.gnupg.org/aegypten/) and pinentry is a part of it:
    "Pinentry: A new module that contains various interfaces (qt, gtk, curses, terminal) to enter a PIN/passphrase."

    The fact that you don't have .gnupg/gpg.conf but .gnupg/options indicates that your gnupg ist not freshly installed-

    From the FAQ http://www.gnupg.org/(en)/documentation/faqs.html#q5.8

    "The ~/.gnupg/options file has been renamed to ~/.gnupg/gpg.conf for new installs as of version 1.1.92. If an existing ~/.gnupg/options file is found during an upgrade it will still be used, but this change was required to have a more consistent naming scheme with forthcoming tools. An existing options file can be renamed to gpg.conf for users upgrading, or receiving the message that the "old default options file" is ignored (occurs if both a gpg.conf and an options file are found)."

    Z.

    By Blogger Zerlinna, at 2/20/2006 05:46:00 nachm.  

  • Strange... I was having Kmail+GPG perfectly working in Edgy, with pinentry not installed... But after the upgrade to Feisty Kmail wasn't asking my passphrase no more... Pinentry intallation resolved the problem, thanks for your how-to!

    By Anonymous montag, at 4/29/2007 12:42:00 nachm.  

Kommentar veröffentlichen

Links to this post:

Link erstellen

<< Home