gpg with gpg-agent never asks for passphrase
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 <[email protected]>"
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 <[email protected]>"
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.
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.
Kind of late, but at this time I face this problem when I do remote login to my PC (Linux-Centos) and try to decrypt a PGP file. I tried dave's suggestion, without luck, googling I found this
gpg: cancelled by user
This part solve my problem:
Finally after allowing other's to r+w on tty seem to solve this issue
[root@host ~]# chmod o+rw $(tty)
Hope this can help someone else.
BR.