gpg cannot unlock passphrase-less key: "gpg: public key decryption failed: No passphrase given"

I solved this by using an older system which had the key.

  • I set a new passphrase on the old system where empty-passphrase input works.
  • Export old system private key and copy it over new system
  • Clean gpg state of new system (move .gnupg to .gnupg.bak)
  • Import the non-empty passphrase private key

Here are the commands I ran:

# put a non-empty passphrase on current key
me@old$ gpg --passwd [email protected]
(leave empty on first prompt)
(put a new non-empty passphrase on 2nd)
(confirm new passphrase)

# now we export it

me@old$ gpg --list-secret-keys                               
/home/xxxxx/.gnupg/secring.gpg
-------------------------------
sec   4096R/AAAAAAAA 2015-01-01
uid                  Foo Bar <[email protected]>
uid                  Bar Foo <[email protected]>
ssb   4096R/BBBBBBBB 2015-01-01

# I've used the first key id (should be 8 hex digits)
me@old$ gpg --export-secret-keys AAAAAAAA > priv.key

# copy key over new system

# backup .gnupg dir just in case
me@new$ mv .gnupg .gnupg.back
# import new priv key
me@new$ gpg --import priv.key
(type new passphrase set previously)

# done!

For completeness sake here are the software versions of both systems, maybe that can help someone:

New system (cannot input empty passphrase) software version:

  • gpg (GnuPG) 2.2.5
  • libgcrypt 1.8.2
  • pinentry-curses (pinentry) 1.1.0

Old system (can input empty passphrase) software version:

  • gpg (GnuPG) 2.0.24
  • libgcrypt 1.6.1
  • pinentry-curses (pinentry) 0.8.3