LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Security (https://www.linuxquestions.org/questions/linux-security-4/)
-   -   GPG: "decryption failed: no secret key" (https://www.linuxquestions.org/questions/linux-security-4/gpg-decryption-failed-no-secret-key-4175735248/)

nicehand90210 03-24-2024 10:47 AM

GPG: "decryption failed: no secret key"
 
I'm new to GPG and am incapable of understanding cryptology. I'm trying to decrypt a message (that should be encrypted for me) and I'm getting the error:

Quote:

gpg: public key decryption failed: No secret key
gpg: decryption failed: No secret key
My private key is listed under "gpg --list-secret-keys". pass works correctly, which suggests to me that there shouldn't be a problem.

Apologies for the n00b question. As I said, I don't understand any of this and can't begin to troubleshoot it on my own. Help greatly appreciated.

business_kid 03-24-2024 11:44 AM

Hello, nicehand90210 & welcome to LQ.

That GPG system uses two keys
  • A private key which you don't share with anybody.
  • A 'public' key which you share only with those who you allow to decrypt your messages

There's a utility for creating the keys. Read the documentation.

jayjwa 03-24-2024 01:21 PM

Make sure you're using the correct version of GPG. There's two major ones: 1 and the newer version 2. The link to "gpg" might give you either. If you don't have a key pair, make one. It seems like you do.

The public key you send out:
Code:

gpg2 --export -a you@your.host.net
Test GPG to yourself to make sure you can sign, encrypt and decrypt properly:
Code:

gpg2 -u you@your.host.net -r you@your.host.net -a --encrypt --sign file.txt
That should ask for your key password and create file.txt.asc. Check you can decrypt it with:
Code:

gpg2 -d file.txt.asc
If this part doesn't work, there's no point in going further. Fix what went wrong first before involving a second party. The -u parameter is in case you have multiple key pairs. On the other end, the person sending to you need set "-r you@your.host.net" to encrypt to you. If decryption is failing, they (the remote party) might not have encrypted to the right key.

GPG is kind of complex (in my opinion the reason it never really caught on outside of techies); you'd do well to spend some time reading a tutorial on it.


All times are GMT -5. The time now is 09:39 PM.