Tell me more ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Is it posible to configure gpg in a way that I enter passphrase only once, and it will work for the whole session (I'm using Ubuntu/XFce)?

I'm not sure how gpg works, it seems that the default function is that gpg asks gpg-agent for the passphrase and the agent runs pin-entry to ask for passphrase.

I would like to use pinentry-curses only once per session, so I can paste my passphrase (I have hex string from a sentence - I use echo -n <SENTENCE> | str-hex) and sign email from Claws Mail without putting passphrase (you can't use pinentry-curses with Claws Mail).

share|improve this question

1 Answer

up vote 2 down vote accepted

You can use the technique described on this page:

http://fvue.nl/wiki/Debian_4.0:_Installing_gpg-agent

Here's the gist:

  1. Install gpg-agent and pinentry program:

    sudo apt-get install gnupg-agent pinentry-curses
    
  2. Add the lines below to ~/.profile. Any POSIX-confirming shell should include this file.

    # Invoke GnuPG-Agent the first time we login.
    # Does `~/.gpg-agent-info' exist and points to gpg-agent process accepting signals?
    if test -f $HOME/.gpg-agent-info && \
        kill -0 `cut -d: -f 2 $HOME/.gpg-agent-info` 2>/dev/null; then
        GPG_AGENT_INFO=`cat $HOME/.gpg-agent-info | cut -c 16-`
    else
        # No, gpg-agent not available; start gpg-agent
        eval `gpg-agent --daemon --no-grab --write-env-file $HOME/.gpg-agent-info`
    fi
    export GPG_TTY=`tty`
    export GPG_AGENT_INFO
    

    This little script will be activated when you login. If the agent is not running, it will be started. When the agent is started, it shows how to set environment variables in order to connect to it. The script saves these values in ~/.gpg-agent-info, so that when you start another login session the script can setup the variables correctly and thus use the agent.

You will only have to enter your passphrase once per boot. The agent will store your keys in memory, so you don't have to enter the passphrase again.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.