Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Without gpg-agent running, I can enter my passphrase to sign things:

$ echo 123 | gpg -s

You need a passphrase to unlock the secret key for
user: "Mr. Ops <ops@bxxx.com>"
2048-bit RSA key, ID 20F31903, created 2014-03-13

gpg: gpg-agent is not available in this session
Enter passphrase:

Works fine. But I don't want to type my passphrase all the time, so I run gpg-agent:

$  eval $(gpg-agent --daemon)

Now I would expect to be prompted for my passphrase at least once, but I never am, and all operations using gpg fail.

$ echo 123 | gpg -s

You need a passphrase to unlock the secret key for
user: "Mr. Ops <ops@bxxxx.com>"
2048-bit RSA key, ID 20F31903, created 2014-03-13

gpg: cancelled by user
gpg: no default secret key: bad passphrase
gpg: signing failed: bad passphrase

How do I get my passphrase stored in the agent? Once I have it there, how do I keep it there across login sessions? (Ideally I never want to be prompted again.) This is on Ubuntu 12.04.4 with the standard apt-get gpg packages, in case it matters.

share|improve this question

1 Answer 1

This happens when gpg-agent doesn't know which TTY to prompt on, which is happening here because you are redirecting stdin.

You can put export GPG_TTY=$(tty) in your ~/.bashrc to setup the TTY for each login shell.

The docs on gpg-agent has more details.

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.