Fix the Error “gpg can’t check signature no public key error”

GNU Privacy Guard usually known as GnuPG or GPG is a free and open-source encryption tool or software that programmers use to encrypt and decrypt the file. It has an encryption method called public key (asymmetric). Programmers use GPG to sign communication and data as well as encrypt the file. It integrates simply with many applications as it is a well-known command line tool offering many features. When working with GPG, you may encounter the error “gpg can’t check signature no public key error”.

We are going to help you solve the error. Let’s first check out how you land up in the error warning

How the error shows up

When you are trying to decrypt a file using a command. This is the command you tried:

gpg --output file.txt --decrypt file.pgp

Though the file seems to be decrypted, you end up with the following error message

"gpg: Can't check signature: public key not found"

You must be wondering what measures you need to take to get rid of this error. Let’s check out the next section to solve the error

How To Fix the Error “gpg can’t check signature no public key error”

We are bringing the best possible approaches to help you get rid of the error efficiently and simply.

Approach 1

The error appears when you have no public key of the one who has signed the message. You should have the massage from gpg that contains the Key’s ID, which is required to sign in. you need to have the key from the one who has encrypted the file along with importing it into the keyring (gp2 –import key.asc). After this, it is required to verify the signature. You would be needing to import the key from the keyserver directly if a keyserver (e.g https://pgp.mit.edu/) of the public key is submitted by the sender:

gpg2 --keyserver https://pgp.mit.edu/ --search-keys <sender_name_or_address>

It’s really helpful when it comes to solving the error warning successfully.

Approach 2

You are required to have the public key in the gpg key ring. You need to set the text file for a public key block with a .gpg extension by importing the public key into the public ring. After this, use the below command:

gpg --import <your-file>.gpg

You should be provided with such a block by the entity, which encrypted the file. For instance,  ftp://ftp.gnu.org/gnu/gnu-keyring.gpg has the block for gnu.org. To have a thorough elaboration, you can check verifying files with GPG with no .asc or .sig file.

It is definitely another approach that can handle the error.

Conclusion

In this post, we have discussed the best approaches to handle the error “gpg can’t check signature no public key error”. The approaches can be simply implemented and make the error go away so that you can continue coding peacefully. I hope you like it and find it interesting! I wish you happy coding!

Leave a Reply

Your email address will not be published. Required fields are marked *