Strange situation here: I changed my GPG password some time ago but when using script to encrypt/decrypt folder, I have to enter my old password to decrypt files.

  • I changed password to my GPG key (gpg passwd )
  • Seahorse will accept only new password
  • When I encrypt file with gpg -ea -r my@email.com file (or with main-key-id), than I'm able to decrypt it with new password

The trouble is, that when I use the command gpg --trust-model always --batch --yes -ea -r <pub-key-ID> <file.txt> in the script, I cannot decrypt file with my new password. Only my old password works.

I'm completely baffled. What could be the problem?

  • Are you sometimes using gpg, sometimes gpg2 (or a GUI application like Enigmail)? – Jens Erat Sep 2 '17 at 15:54
  • Yes, I use enigmail as well while using "gpg" command in scripts. gpg --version returns gpg (GnuPG) 2.1.11, libgcrypt 1.6.5. But this problem occures when using only gpg commands. Weird. – Sebastian Sep 3 '17 at 9:22
  • It seems that this problem is still unsolved. I tried to change password via gpg --edit-key xxxxxx as well as gpg2 --edit-key xxxxxx, but it won't fix it. In same cases, my old password is the only one that works. – Sebastian Mar 2 '18 at 11:56
  • Make sure you don't use GnuPG with multiple user accounts or have special keyrings stored on non-default locations (but then again, these would not be picked up normally). – Jens Erat Mar 2 '18 at 12:04
  • I moved .gnupg folder to encrypted location and symlinked it back. Is there anything else I have to do? I noticed, that I cannot decrypt file in script but the same command in terminal works just fine. Some environmental problems? – Sebastian Mar 2 '18 at 12:22

I figured it out afterall:

  • There were different secret keys in gpg and gpg2
  • I had an alias alias gpg="gpg2"
  • Script was working with "gpg" while shell worked with gpg2 (even when I thought the otherwise)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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