GPG : "No secret key found" error
Robert J. Hansen
rjh at sixdemonbag.org
Tue Jun 8 12:10:24 CEST 2021
Please do not send HTML to this mailing list. Many of our members
refuse to open HTML emails from unknown parties, so when you send HTML
email to this list you're limiting the number of people who can see your
question -- and maybe be able to help you!
> Step 2. Instead, I have thought of storing the passphrase in a file
> (passphrase.dat.pgp), encrypted that file without password and passing
> the password to do the work using below command.
How exactly do you "encrypt that file without password"?
At any rate, this is probably a bad idea. Often the best way to proceed
for scripting GnuPG tasks is to remove the passphrase from the certificate.
> Step 3. To my wonder, when I execute Step 1 first and then Step 2
> (within a short span), it works, but if I directly run Step 2 ( which
> actually will be happening as a part of solution), then it doesn't and
> fails for "No secret key" error.
This tells me that GnuPG is caching your passphrase with gpg-agent.
When you run it the second time GnuPG sees the passphrase is in the
cache and uses that, without ever needing to ask you for the passphrase.
More information about the Gnupg-users
mailing list