TL;DR
To fix the “gpg: no valid OpenPGP data found” error on your Linux system, try these solutions:
- Fix the Outdated Software: Ensure GPG is up-to-date using sudo apt update && sudo apt upgrade, then restart with gpgconf –kill gpg-agent && gpgconf –reload gpg-agent.
- Check for Improperly Formatted or Corrupted Files: Verify files with gpg –list-packets filename.gpg and re-import using gpg –import publickey.asc.
- Install CA Certificates: Install CA certificates with sudo apt update && sudo apt install ca-certificates.
- Change the Path in the .bashrc File: Add export CURL_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt to .bashrc and save changes.
Learn more about how to fix the “gpg: no valid OpenPGP data found” error in the detailed guide below.
Running into errors can be really frustrating, especially when you’re in the middle of something important. If you’ve seen the “gpg: no valid OpenPGP data found” error, don’t worry—there’s a way to fix it. This post will help you solve this problem with easy steps. We’ll cover how to update your software, check for corrupted files, and set up key servers correctly. By the end, you’ll know exactly what to do to fix this error and keep it from happening again.
What is the gpg: no valid OpenPGP data found
Error?
The gpg: no valid OpenPGP data found
error happens when you try to import a PGP key using GPG (GNU Privacy Guard), but GPG can’t find any valid key data in the file or URL you provided. This means the key file might be:
- Corrupt
- Incorrectly formatted
- Incomplete
Alternatively, there might be a problem with the URL where the key is located.
How to Fix the gpg: no valid OpenPGP data found Error
To fix the “gpg: no valid OpenPGP data found” error, start by updating your GPG software. Use the command sudo apt update && sudo apt upgrade
to ensure you have the latest version. Then, restart GPG with gpgconf --kill gpg-agent && gpgconf --reload gpg-agent
. This should resolve the issue.
Here’s the detailed step-by-step guide for this method and six other methods to fix the “gpg: no valid OpenPGP data found” error:
1. Fix the Outdated Software
Make sure both GPG and OpenPGP software are up-to-date and compatible to avoid or fix the “gpg: no valid OpenPGP data found” error. Here are the steps to update GPG and OpenPGP:
- Check the newer version of GPG by running the command:
sudo apt update && sudo apt upgrade
- To install the newer version of GPG, use the command:
sudo apt install gnupg
- After running these commands, you’ll have this output:

- Now, restart GPG with the following commands:
gpgconf --list-dirs
gpgconf --kill gpg-agent
gpgconf --reload gpg-agent
Alternatively, you can use this command to restart GPG:
sudo systemctl restart gpg

- Now, try decrypting or verifying the OpenPGP data again.
gpg -c filename.extension
- Once you execute this command, you’ll have to enter the passphrase for this file.

- If the command is successful, you’ll see the following output:

2. Check for Improperly Formatted or Corrupted Files
Sometimes, you may see the “gpg: no valid OpenPGP data found” error when the files are corrupt or improperly formatted. If that’s the case, follow these steps:
- Check if the file is complete and not corrupted by running the command:
gpg --list-packets filename.extension.gpg
- Enter the passphrase that you had entered for this file to let the Terminal read the packets.

- You’ll see the following output:

- If the file is corrupted, try downloading it from a trusted source again. But if the file is complete but encrypted with a different public key, obtain the correct public key and import it into GPG using the command:
gpg --import publickey.asc
3. Install CA Certificates
If you are experiencing the “gpg: no valid OpenPGP data found” error while using GPG, installing the CA certificate onto your system can help to resolve the issue. This is because GPG relies on digital certificates to authenticate and encrypt messages, and the absence or corruption of these certificates can cause this error message to appear. To install the CA certificate on your system, you can follow these steps:
- Execute the following code to install CA certificates:
sudo apt update && sudo apt install ca-certificates
- Wait for the update and the new CA certificate installation process to complete.

- If your Linux packages and CA certificates are already updated and installed on your system, you will see a message indicating this on your Terminal.

4. Change the Path in the .bashrc File
If the “gpg: no valid OpenPGP data found” error is caused by the computer looking for the CA certification in the wrong path, you can change the path in the .bashrc file.
- Use the following command to open the .bashrc file executable script file:
nano ~/.bashrc
- Once the file opens, add the following command to it:
export CURL_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt
- Press Ctrl + O to save the file and Ctrl + X to exit the nano editor.

- This command will add the correct path to the file, and the “gpg: no valid OpenPGP data found” error should no longer occur.
5. Refresh the Keyring
To fix the “gpg: no valid OpenPGP data found” error, try refreshing the keyring. To do this, you have to:
- Execute the following command in the Terminal app:
gpg --refresh-keys
- Wait for the refreshing process to complete.

- Once this process is complete, try to decrypt the file or verify the OpenPGP signature and check if the error is resolved.
6. Verify the Keyring Settings
Ensure that the keyring settings are correct. Follow the steps below to verify the keyring settings:
- In the Terminal app, enter the following command:
gpg --list-keys
- You’ll see the list of gpg keys stored on your Linux system.

- If you see an error message, the keyring settings are incorrect. To fix the settings, enter the following command:
gpg --recv-keys <key-id>
Replace <key-id> with the correct ID for your key.
7. Incorrect GPG Keyserver Configuration
Another reason for the “gpg: no valid OpenPGP data found” error is the incorrect GPG keyserver configuration. To ensure that it is properly configured, follow these steps:
- Check the keyserver settings by running the command:
gpg --version
- Look for the Home entry in the output and note the location of the configuration file.

- Now, check the current keyserver settings by running the following command:
gpgconf --list-options gpg | grep keyserver
- This command will display the current keyserver settings in the Terminal Window.

- If the keyserver settings are wrong or outdated, update it with the command below while replacing the
/.gnupg
with the path to your GPG home directory:
gpgconf --homedir ~/home/farah/.gnupg --kill all && gpgconf --homedir /home/farah/.gnupg --reload gpg
- To verify that the keyserver settings have been updated to the default keyserver, run the following command:
gpgconf --list-options gpg | grep keyserver
- You’ll see the following output:

7 Tips to Prevent “gpg: no valid OpenPGP data found” Error
To prevent the “gpg: no valid OpenPGP data found” error from occurring in the future, it’s important to follow best practices. Here are some of them to consider:
- 🔑 Keep keyring settings and GPG up-to-date: Update the keyring settings so that GPG can find the necessary key to decrypt files and verify OpenPGP signatures. You can run
sudo apt-get update && sudo apt-get install gnupg
to update the package list and install the GnuPG package. Then, executegpg --refresh-keys
to fetch the latest public key updates from the key server. - 🔍 Verify OpenPGP data before decryption: Verify the validity of OpenPGP data before decrypting a file to prevent corrupted or invalid data issues, including the “gpg: no valid OpenPGP data found” error. You can run
gpg --verify <filename>
to verify the OpenPGP data. - 💾 Keep a backup of the keyring: Use
gpg --export-secret-keys > mykeyring_backup.asc
to keep a backup of the keyring. This command will export your secret keys and save them to a file named “mykeyring_backup.asc” in your current working directory. You can then copy this file to a secure location.. - 🔑 Use reputable keyservers for public keys: To ensure key authenticity, it’s important to use reputable keyservers to obtain public keys. Some examples of reputable keyservers include keyserver.ubuntu.com and keys.openpgp.org.
- 🛡️ Check GPG keys and files before use: Before using GPG keys and files, it’s important to verify that they’re not corrupted. This can help prevent issues related to corrupted files, which may cause the “gpg: no valid OpenPGP data found” error. You can use the
gpg --check-sigs <filename>
command to check the GPG keys and files. - 🔒 Use trusted sources for OpenPGP data: To prevent issues related to malicious data, only use trusted sources when obtaining OpenPGP data. It can help you to avoid the “gpg: no valid OpenPGP data found” error due to the use of untrusted data.
To Sum Up
In this article, I’ve covered several methods to fix the “gpg: no valid OpenPGP data found” error. I also discussed updating outdated software, checking for improperly formatted or corrupted files, installing CA certificates, and refreshing the keyring.
If you want to learn more, here are a few additional readings you might find helpful:
- Find out how to resolve the “please install all available updates before upgrading” error to ensure smooth system upgrades.
- Discover how to encrypt files in Linux to protect your sensitive data.
- Learn how to fix the “You Have Held Broken Packages” error to resolve package installation issues.