How to fix “gpg: no valid OpenPGP data found error”

Installing any software differs a lot to behave on Linux and Windows. In Ubuntu, a simple apt install command can retrieve various software and install it onto the system. However, the apt install does not always do the job and third-party installers must be used to get software onto your system. For this, you may require wget and curl utilities. But making use of these utilities can oftentimes cause the “gpg: no valid OpenPGP data found” error.

This article will provide the reasons for the error “gpg: no valid OpenPGP data found” and what can be done to fix this issue.

How to Fix “gpg: no valid OpenPGP data found”

A few different reasons exist which can cause this error to pop up on a system while trying to use the features of wget or curl. This post discusses a lot of common causes behind this issue.

Reason 1: No Certification

The corporation certificates are the common reason that invokes this error. Sometimes the company that develops the software will have its own certification which will be enabled by default and hence this error will be invoked. When this happens, the error shown in the snippet below will occur:

Solution 1: Remove the Certification Check

If any software has its own certification, it can easily be removed during the command line execution. Let’s take a sample command for this scenario. This code which is demonstrated below, is used to download a file that contains keys using the wget command.

wget -qO - http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key | sudo apt-key add -

To remove the certification from this software, use the following flag in the abovementioned command:

--no-check-certificate

After adding the flag, the command looked like as:

wget --no-check-certificate -qO - http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key | sudo apt-key add -

Solution 2: Install certificates

Aside from removing the certification, the other solution is to install the CA certificates onto your system. This is a tool that helps store and generate certificates. Its installation can be achieved by executing the code that is shown below:

$ sudo apt update
$ sudo apt install ca-certificates

If the certificates are already installed, the following message will appear on your terminal:

Reason 2: Wrong Path for Certificates

Sometimes the error is invoked when the computer is looking for the CA certification in the wrong path. The curl command is unable to locate the correct root CA path. Let’s see how it can be fixed:

Solution: Change the Path in the .bashrc File

The bashrc is a type of executable script file. The first step to changing the path in the bashrc is to open up the file itself. To achieve this, execute the following command which will prompt the .bashrc file to open:

$ nano ~/.bashrc

The file should look something like the one shown below once it has been opened up:

The next step is to add the path to this file. Add the command shown below into the file and save and exit it:

export CURL_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt

Once the command has been added to the file, the error should no longer occur and the command will run.

Conclusion

The “gpg: no valid OpenPGP data found” error occurs due to certification issues regarding the software that is to be installed using wget or curl.It can be fixed by removing the certification check in the command line. Moreover, ensure that the latest version of the CA certificates is installed on the system at the correct path. This post has demonstrated the methods to fix the error “gpg: no valid OpenPGP data found”.