I'm having an issue decrypting files with gpg2. I originally encrypted the files with gpg version 1.4. The machine I'm on now has both gpg (1.4) and gpg2. Decryption with gpg works just fine, but when I execute the same command with gpg2, it times out:

$ echo "This is a test" > test.txt
$ gpg -r MyOwnId --encrypt test.txt
  (creates test.txt.gpg)
$ gpg --decrypt test.txt.gpg
  (provide passphrase for MyOwnId)
  -> This is a test
$ gpg2 --decrypt test.txt.gpg
  (after a long timeout)
  -> gpg: encrypted with 2048-bit RSA key, ID #######, created YYYY-MM-DD "MyOwnId"
     gpg: public key decryption failed: Timeout
     gpg: decryption failed: No secret key

What's going on? It says "No secret key", but running gpg2 --list-secret-keys shows this:

sec   rsa2048/######## YYYY-MM-DD
uid         [ unknown] MyOwnId
ssb   rsa2048/######## YYYY-MM-DD

Update 1:

Looks like the problem isn't with gpg2 itself, but rather with my Gnome keyring or something. Previously, when I tried to decrypt files with gpg2, it would simply hang, then time out. However, once I encrypted a test file with my own key, then decrypted that file, it prompted me for my passphrase. Now that my passphrase is in my keyring, everything's working. Might have just been a temporary thing (I logged out and back in between then and now). If anyone has more info on issues like this, I'd love to know. I'll give it another day or two, then close the question if it doesn't happen again.

  • 1
    I've just got a similar issue. I needed to change the pinentry program from pinentry-qt4 to pinentry-qt in ~/.gnupg/gpg-agent.conf in order to resolve this issue.
    – antoyo
    Dec 11, 2015 at 16:57
  • Can't believe how much time I wasted on this issue until I stumbled on this comment. The 'No secret key' message is definitely misleading in a situation when the actual issue is with the pinentry executable, not with the presence or absence of the secret key. In my case, it was simply a matter of editing gpg-agent.conf and specifying the full path to the pinentry executable.
    – thomp45793
    Aug 17, 2016 at 5:15
  • 1
    This happens with gpg2.1.5 encrypted file with ssb subkey only (sec key works fine), gpg2.1.5 cannot decrypt its own output, but gpg1.4 is able to decrypt the same data. On win7.
    – mosh
    Oct 13, 2016 at 15:06
  • 1
    For others who have the same problem: I just needed to restart gpg-agent. Mar 27, 2018 at 15:20

1 Answer 1


I was having the same issue and as Martin Kunev told, you could just try by restarting gpg-agent, like this https://superuser.com/a/1150399

gpgconf --kill gpg-agent

Next time it's needed it will be restarted automatically.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .