140

I am trying to install Jenkins on Ubuntu 13.10 and I am getting the above mentioned error when i try to run the following command:

wget -q -O - http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key | sudo apt-key add -
Philipp Kyeck
  • 18,402
  • 15
  • 86
  • 123
dummy
  • 1,573
  • 2
  • 10
  • 11

20 Answers20

137

This problem might occur if you are behind corporate proxy and corporation uses its own certificate. Just add "--no-check-certificate" in the command. e.g. wget --no-check-certificate -qO - http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key | sudo apt-key add -

It works. If you want to see what is going on, you can use verbose command instead of quiet before adding "--no-check-certificate" option. e.g. wget -vO - http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key | sudo apt-key add - This will tell you to use "--no-check-certificate" if you are behind proxy.

Louis Lac
  • 5,298
  • 1
  • 21
  • 36
Lake
  • 1,397
  • 1
  • 8
  • 4
  • 2
    I don't know what this does but it seems to have fixed another issue for me for downloading a Microsoft key into GPG – Piotr Kula Sep 13 '17 at 08:25
  • 1
    This should be the answer. This worked for me for AWS EC2 – Sankofa Jul 30 '19 at 14:22
  • 10
    I did `curl -fsSL --no-check-certificate https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -` but it gave me `command not found` and `gpg: no valid OpenPGP data found.` error. – Chan Kim Nov 07 '19 at 07:57
  • 9
    @Chan Kim: `--no-check-certificate` is a command-line option for `wget`, not `curl`. – snark Mar 31 '20 at 13:24
  • 3
    I would caution any who read this answer as this seems very dangerous, considering the question is regarding GPG. Not validating that the certificate ensures that you do not check who actually issued this key, bypassing a very important step, ensuring that the key was given from a trusted server. By doing this you do not know if the server is spoofing the server who you think you are talking to, compromising the validity of the key to be used in GPG. Maybe you need to refresh your keys? `gpg --keyserver hkp://keyserver.ubuntu.com --refresh-keys` – thecoolestname36 Oct 27 '21 at 02:11
66

I got this error in an Ubuntu Docker container. I believe the cause was that the container was missing CA certs. To fix it, I had to run:

apt-get update
apt-get install ca-certificates
Yevgeniy Brikman
  • 8,711
  • 6
  • 46
  • 60
61

Managed to resolve it. separated the command in to two commands and used directly the file name which was downloaded example -

wget -q -O - https://pkg.jenkins.io/debian/jenkins-ci.org.key | sudo apt-key    add -

can be separated into

  1. wget -q -O - https://pkg.jenkins.io/debian/jenkins-ci.org.key
  2. sudo apt-key add jenkins-ci.org.key
Kevin Burke
  • 61,194
  • 76
  • 188
  • 305
Zia
  • 2,365
  • 2
  • 17
  • 14
  • 3
    This worked for me, adding "jenkins-ci.org.key" after -O in the first command. – Arno Apr 06 '18 at 11:57
  • When I tried to execute above commands, faced error saying 'no such file or directory named jenkins-ci.org.key' . As a work around I created file with name 'jenkins-ci.org.key' and executed above commands and it worked like charm!! . – Tapan Hegde Sep 19 '21 at 17:13
  • You can pipe them. Try `| APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=1 apt-key add -` – Kenji Noguchi Mar 10 '22 at 08:15
23

gpg: no valid OpenPGP data found.

In this scenario, the message is a cryptic way of telling you that the download failed. Piping these two steps together is nice when it works, but it kind of breaks the error reporting -- especially when you use wget -q (or curl -s), because these suppress error messages from the download step.

There could be any number of reasons for the download failure. My case, which wasn't exactly listed so far, was that the proxy settings were lost when I called the enclosing script with sudo.

Brent Bradburn
  • 51,587
  • 17
  • 154
  • 173
  • 1
    In my case (`https://dl.winehq.org/wine-builds/winehq.key`) it was because of a bad cert. Strangely enough, chrome accepts the `https` connection, but `wget` (on Ubuntu 18.04) complains. I assume Chrome and linux are using different certificate chains. The key to understand the problem was to remove the `-q` flag from `wget` as you suggest, and the problem became plain and clear. I had to add `--no-check-certificate` for `wget` to work. – blueFast Feb 19 '19 at 07:16
  • `curl` also has `--show-error` >When used with -s, --silent, it makes curl show an error message if it fails. – Brent Bradburn Feb 19 '19 at 12:02
19

I too got the same error, when I did this behind a proxy. But after I exported the following from a terminal and re-tried the same command, the problem got resolved:

export http_proxy="http://username:password@proxy_ip_addr:port/"
export https_proxy="https://username:password@proxy_ip_addr:port/"
Aananth C N
  • 428
  • 7
  • 14
6

i got this problem "gpg-no-valid-openpgp-data-found" and solve it with the following first i open browser and paste https://pkg.jenkins.io/debian/jenkins-ci.org.key then i download the key in Downloads folder then cd /Downloads/ then sudo apt-key add jenkins-ci.org.key if Appear "OK" then you success to add the key :)

Hesham Magdy
  • 61
  • 1
  • 3
6

I had a similar issue.

The command I used was as follows:

wget -qO https://download.jitsi.org/jitsi-key.gpg.key |  apt-key add -

I forgot a hyphen between the flags and the URL, which is why wget threw an error.

This is the command that finally worked for me:

wget -qO - https://download.jitsi.org/jitsi-key.gpg.key |  apt-key add -
MoralJustice
  • 111
  • 1
  • 5
3

In my case, the problem turned out to be that the keyfile was behind a 301 Moved Permanently redirect, which the curl command failed to follow. I fixed it by using wget instead:

wget URL
sudo apt-key add FILENAME

...where FILENAME is the file name that wget outputs after it downloads the file.

Update: Alternatively, you can use curl -L to make curl follow redirects.

Soren Bjornstad
  • 1,292
  • 1
  • 14
  • 25
2

you forgot sudo ... try with sudo and you will get OK

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

Try executing the commands separately.

 wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc

then

sudo apt-key add -
Milind
  • 23
  • 6
1

By executing the following command, it will save a jenkins-ci.org.key file in the current working directory:

curl -O http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key

Then use the following command to add the key file:

apt-key add jenkins-ci.org.key

If the system returns OK, then the key file has been successfully added.

Ryan Yuan
  • 2,396
  • 2
  • 13
  • 23
1
export https_proxy=http://user:pswd@host:port
                   ^^^^

Use http for https_proxy instead of https

lonsty
  • 185
  • 2
  • 10
  • replacing https to http worked for me.. Before replace : "wget -qO- https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -" , After replace : "sudo wget -qO- http://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -" – Jay Teli Sep 23 '20 at 19:55
1

install gpg and

1-Import the repository’s GPG key:

wget -qO - https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add -
    

2-this is code repository elasticserach in linux for download

echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-7.x.list

3-link download elasticsearch

  https://www.elastic.co/downloads/elasticsearch

if error "Job for elasticsearch.service failed because a timeout was exceeded. See "systemctl status elasticsearch.service" and "journalctl -xe" for details."

solution:

1-sudo journalctl -f

2-sudo systemctl enable elasticsearch.service

3-sudo systemctl start elasticsearch

Netwons
  • 1,170
  • 11
  • 14
1

I guess the issue is with wrong GPG key. Jenkins changed their GPG key recently (16 April 2020). You might need to import the correct key following the current official directions.

wget -q -O - https://pkg.jenkins.io/debian/jenkins.io.key | sudo apt-key add -

Tapan Hegde
  • 1,222
  • 1
  • 8
  • 25
0

wget may not be using up to date root certificates. In that case it will output nothing to stdout, causing apt-key to throw the error of the description. I could resolve this by upgrading my debian 9.5 image to the latest 9.13

apt-get update
apt-get upgrade -y

before running wget

AlejandroVD
  • 1,576
  • 19
  • 22
0

There's another, very basic reason that triggers the error message that is the title of this post:

This error message happens if you try to decrypt an unencrypted file.

The message is saying that gpg did try to read the file to decrypt, but it could not find the info it needed, the info the encrypt process writes there.

So the message can also mean "double-check you gave the correct file to decrypt, it looks like it is not an encrypted file".

Like this:

# Encrypt your file
encrypt my_text_file > my_encrypted_file

# ERROR! You try to decrypt the unencrypted file DON'T DO THIS
decrypt my_text_file > decrypted_file
gpg: no valid OpenPGP data found. 
gpg: decrypt_message failed: Unknown system error

# You unencrypt the correct (encrypted) file and it works 
decrypt  my_encrypted_file > decrypted_file
CyclingDave
  • 1,150
  • 1
  • 10
  • 22
0

I have solved the error gpg: no valid OpenPGP data found. For my Ubuntu 20.04 Firstly:

sudo apt-get update

then,

sudo apt-get install ca-certificates

Finally,

sudo apt install curl

0

For those facing gpg: no valid OpenPGP data found. during docker installation due to curl: (5) Could not resolve proxy: could clear their list of proxies and try again;

env | grep -i proxy  //for listing all proxies
unset <name of the proxy>  // remove all proxies that is shown in the error 

Example :

unset http_proxy
unset HTTPS_PROXY
0

Solution 1 - Update CA certificates

Update your system's certificate authorities (CA) certificates to ensure they are current and can verify SSL certificates correctly. In Ubuntu, you can do this with the following command:

sudo apt-get install --reinstall ca-certificates

Solution 2 - Use wget instead of curl

If updating the CA certificates doesn't resolve the issue, try using wget instead of curl to download the Docker GPG key

sudo wget -O /usr/share/keyrings/docker-archive-keyring.gpg https://download.docker.com/linux/ubuntu/gpg

Solution 3 - Check your network and firewall settings

Make sure your internet connection is working correctly, and there are no firewall rules or other network restrictions preventing the secure connection to the "download.docker.com" server. You can try accessing the URL directly in your web browser to check if it's accessible.

Solution 4 - Verify DNS settings

Ensure that your DNS settings are configured correctly. If your DNS server is not resolving the hostname properly, it can lead to SSL certificate verification issues. You can check your DNS settings by running:

cat /etc/resolv.conf

Solution 5 - Disable SSL certificate verification (not recommended)

Please note that disabling SSL certificate verification is not recommended from a security standpoint. However, as a temporary workaround for testing purposes, you can use the --insecure option with curl to ignore SSL certificate verification:

sudo curl -fsSL --insecure https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
-4

I also got the same error. I've referred to the below mentioned link and ran this commands

gpg --import fails with no valid OpenPGP data found

gpg --import KEYS
sudo apt-get update

It worked.

I'm using Ubuntu version 12.04

Community
  • 1
  • 1
DheerajG
  • 97
  • 2
  • 7
  • this means `gpg --import KEYS` will bypass (work like) `apt-key add KEYS`? – Aquarius Power Feb 22 '15 at 18:00
  • Unfortunately, I dont understand how to apply this solution. How does the text "gpg --import KEYS" "sudo apt-get update" relate to the command "wget -q -O - http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key | sudo apt-key add -"? what is KEYS? if you dont now need to use wget, how do you get the key? If I try "# gpg --import KEYS" i get a lot of errors, including "pgp: cant open KEYS: no such file or directory" – John Little Nov 12 '15 at 14:20
  • maybe he meant the word KEYS as a placeholder for your key source URL. – Alexander Stohr Jul 26 '19 at 11:47