The following two commands are separated by a pipe | character, which means they will be executed together, in one go:

wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -

I need to run them separately, as two commands.

Actually these commands download and install the public signing key for elastic search.

But for some reason, they are giving me

gpg: no valid OpenPGP data found.

My web search tells me that executing both the commands separately might solve my problem. So I am trying to do that.

So the first command wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch returns fine, while the second one sudo apt-key add - goes forever, and never returns.

  • 1
    - means use STDIN as input (ie the STDOUT of the command before the pipe). You need to give the key, if you are not piping to the command. – Zanna Oct 6 '17 at 10:50
  • @Zanna Is there a way to somehow assign the key obtained as a result of 1st command to some kind of variable, and then use that variable in the second command? – Shy Oct 6 '17 at 10:52
  • yes, do mykey=$(wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch) – George Udosen Oct 6 '17 at 10:54
  • @George and then do sudo apt-key add $mykey in the second command right? – Shy Oct 6 '17 at 11:01
  • See my answer below and just tested it – George Udosen Oct 6 '17 at 11:04

First run:

wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch -O mykey

Then run:

sudo apt-key add <<< mykey
| improve this answer | |
  • The second one still gives me gpg: no valid OpenPGP data found. – Shy Oct 6 '17 at 11:07
  • But this means the method to run those commands separately is correct, which answers this question. So thank you. – Shy Oct 6 '17 at 11:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.