Starting gpg-agent from Xsession

Albrecht Dreß albrecht.dress at
Sat Jan 22 14:33:25 CET 2005

Am 22.01.05 11:22 schrieb(en) Peter Eisentraut:
>   if [ -x /usr/bin/gpg-agent ] && [ -z "$GPG_AGENT_INFO" ]; then
>     eval `gpg-agent --daemon`

I recommend adding

echo $GPG_AGENT_INFO > $HOME/.gpg-agent-info

here... Now add

if [ -z "$GPG_AGENT_INFO" ] ; then
     if [ -f $HOME/.gpg-agent-info ] ; then
         export GPG_AGENT_INFO=$(cat .gpg-agent-info)
export GPG_TTY=$(tty)

to $HOME/.bashrc, so even if the user logs in on a virtual console, the  
agent will be found, and it will automagically use the curses pinentry if  

> The problem that I see, however, is that this does not terminate the
> gpg-agent when the X session finishes (unlike ssh-agent).  I've also
> played with a number of other invocation methods such as --server,
> --no-detach, or invoking the window manager as an argument of gpg-agent
> (which is how ssh-agent does it), without success.

I'm using gdm, and I simply added the following to the beginning of the  
file /etc/X11/gdm/PostSession/Default:


if [ -f $GPGAGENTINFO ] ; then
     AGENTPID=$(cat $GPGAGENTINFO | sed -e 's/^[^:]*://' -e 's/:.*//')
     if [ -n "$AGENTPID" ] ; then
         kill -TERM $AGENTPID > /dev/null 2>&1
     rm -f $GPGAGENTINFO

Works perfectly for me... I guess you'll have to tweak other files if you  
are using xdm or kdm, though.

Hope this helps,


  Albrecht Dreß  -  Johanna-Kirchner-Straße 13  -  D-53123 Bonn (Germany)
        Phone (+49) 228 6199571  -  mailto:albrecht.dress at
    GnuPG public key:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : /pipermail/attachments/20050122/ac83b971/attachment.pgp

More information about the Gnupg-devel mailing list