'sudo apt-get update' does not work after trying to install elasticsearch through apt-get

First, I tried to install elasticsearch according to the instructions on the website https://www.elastic.co/guide/en/kibana/current/deb.html

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

deb https://artifacts.elastic.co/packages/8.x/apt stable main 

but after that, when I try to $ sudo apt-get update

> E: Conflicting values set for option Signed-By regarding source > https://artifacts.elastic.co/packages/8.x/apt/ stable: > /usr/share/keyrings/elasticsearch-keyring.gpg != E: The list of > sources could not be read. 

but in keyrings, there is no elasticsearch-keyring.gpg

in keyrings,

docker-archive-keyring.gpg ubuntu-advantage-ros.gpg ubuntu-advantage-cc-eal.gpg ubuntu-archive-keyring.gpg ubuntu-advantage-cis.gpg ubuntu-archive-removed-keys.gpg ubuntu-advantage-esm-apps.gpg ubuntu-cloudimage-keyring.gpg ubuntu-advantage-esm-infra-trusty.gpg ubuntu-cloudimage-removed-keys.gpg ubuntu-advantage-fips.gpg ubuntu-master-keyring.gpg 

I already changed the file sources.list from /usr/share/doc/apt/examples/ to /etc/apt/
for reset the list

I don't know how to get it back. I can't install any package through apt now

someone please, help me T_T

4 Answers

I am by no means a linux or elasticsearch expert. I don't know if this is a GOOD solution. It could be a very nasty and BAD solution.

...But it allowed me to use apt-get again when I was having the same problem. Who knows, maybe the people who actually know the "correct" solution will respond if I trigger them with a dirty hack, haha.

In /etc/apt/sources.list.d, there's a file called "elastic-8.x.list", the same one used in the command you used above for installation. I removed the file and I could use apt-get again.

sudo rm /etc/apt/sources.list.d/elastic-8.x.list 

I also removed the elasticsearch keyring, but that on it's own didn't work. It was removing the elastic list file that allowed things to work again.

sudo rm /usr/share/keyrings/elasticsearch-keyring.gpg 

I hope my answer was helpful!

I had the same situation when trying to install Kibana after installing the Elasticsarch. Try these steps:

  • Edit file: sudo nano /etc/apt/sources.list.d/elastic-8.x.list
  • Delete the following line: deb [signed-by=/usr/share/keyrings/elasticsearch-keyring.gpg] https://artifacts.elastic.co/packages/8.x/apt stable main
  • Re-install Kibana
  • For me there was repeating deb https://artifacts.elastic.co/packages/8.x/apt stable main removing those repeating code worked.

    The below steps worked for me.

    STEP-1: Remove gpg file

    rm /usr/share/keyrings/elastic.gpg 

    STEP-2 Remove this entry

    deb [signed-by=/usr/share/keyrings/elastic.gpg] https://artifacts.elastic.co/packages/7.x/apt stable main 

    from /etc/apt/sources.list.d/elastic-7.x.list

    STEP-3

    apt-get update 

    ncG1vNJzZmirpJawrLvVnqmfpJ%2Bse6S7zGiorp2jqbawutJobmptZWiAdXyOrKydp12WvbV5xp6rZq2gma61sYydpp6rXaO8tXnWqKmkZZGbwaa%2BjK2psqGenHq1u4yipayskaG5brHLmqqtoZOosqK%2BwqFkraCipMKo