Getting error im decrypting .gpg file

2

I'm getting an error in decrypting .gpg file. I've already imported the public keys through below method.

$gpg --import key1.asc
directory `/user_home/.gnupg' created

gpg: new configuration file
`/user_home/.gnupg/gpg.conf' created

gpg: WARNING: options in `/user_home/.gnupg/gpg.conf' are not yet active during this
run

gpg: keyring `/user_home/.gnupg/secring.gpg' created
gpg: keyring `/user_home/.gnupg/pubring.gpg' created
gpg: /user_home/.gnupg/trustdb.gpg: trustdb created
gpg: key 3CDDKLPD: public key imported
gpg: Total number processed: 1
gpg:imported: 1  (RSA: 1)

$gpg --import key2.asc
gpg: key 4F23B654: public key imported
gpg: Total number processed: 1
gpg: imported: 1  (RSA: 1)

$gpg --list-public-keys
/user_home/.gnupg/pubring.gpg
pub   2048R/3CDDKLPD

uid                 
pub   2048R/4F23B654
uid

$gpg --decrypt myfile.txt.gpg
gpg: encrypted with 2048-bit RSA key, ID 4F23B654, created 2010-07-11

gpg: decryption failed: No secret keykey

This error occurs though so, can someone help determine why this is happening? I will appreciate it.

Shanil Soni

Posted 2015-12-04T17:25:42.817

Reputation: 121

per this, you may have failed to import the secret keys from the old keyring: http://stackoverflow.com/questions/91355/gnupg-decryption-failed-secret-key-not-available-error-from-gpg-on-windows

– Frank Thomas – 2015-12-04T17:33:50.217

Who did crypt the message, your self? As far I understand, the message was crypted with the public key, and only the owner of the private key will be able to read the message. – Mathieu – 2015-12-04T17:34:20.057

FYI, it appears he is decrypting a file rather than a message by the way. I edited the question to put the error detail in a more readable format to help as well. Once approved you'll see it that way as well. – GambleNerd – 2015-12-04T19:10:53.343

Answers

1

They should be encrypting files they send to you to decrypt with your PUBLIC key and you should be encrypting files for them to decrypt with their public key. It seems that they encrypted the file with their public key rather than yours, so since you DO NOT have their PRIVATE key, then you cannot decrypt those files.

I'd reach out to them and ask them to confirm that they have imported your PUBLIC key and resend that to them, show them this detail you posted above, and ask them to encrypt it with your PUBLIC key and then resend it for you to try to decrypt again.

If you are testing to ensure you can decrypt files with your private key, then encrypt a test file with your own PUBLIC key and not someone else's which you do not have the correlated PRIVATE key to decrypt, that's how this type of key pair encryption/decryption works.


You importing their public key to encrypt files with this before sending to them

$gpg --import key2.asc

gpg: key 4F23B654: public key imported

gpg: Total number processed: 1

gpg: imported: 1  (RSA: 1)

You decrypting the file they sent to you but getting an error stating you do have have the keypair to unlock this file since they encrypted it with their public key rather than your public key. Only they can unlock/decrypt files encrypted with their public key, that's why it's the public key you can share with anyone.

$gpg --decrypt myfile.txt.gpg

gpg: encrypted with 2048-bit RSA key, ID 4F23B654, created 2010-07-11

gpg: decryption failed: No secret key

GambleNerd

Posted 2015-12-04T17:25:42.817

Reputation: 486