Featured image of post apt-get update fails with Unknown error executing apt-key

apt-get update fails with Unknown error executing apt-key

Note

In “earlier” days you could easily add missing GPG keys with a command like:

apt-key adv --keyserver keyserver.ubuntu.com --recv-keys D68FA50FEA312927

BUT most modern distributions will tell you

apt-key is deprecated. manage keyring files in trusted.gpg.d instead

So you should stop using it and use gpg directly ,

  • you might export the old keys by issuing apt-key list and then using the last 8 characters like this

    sudo apt-key export 3A798D29 | sudo gpg --dearmour -o /etc/apt/trusted.gpg.d/mysql-key.gpg

  • For external GPG Pubkeys ( new repos e.g. ) from now on add them like this :

    KEYRING=/usr/share/keyrings/yourpackagename.gpg
    curl -fsSL https://server.lan/key-path-to-download | gpg --dearmor | sudo tee "$KEYRING" >/dev/null
    

Error indicators

Obviously apt/apt-get update will output

apt-get update fails with Unknown error executing apt-key ,

Errors you might face when trying to manually run apt-key look like:

    /usr/bin/apt-key: 710: touch: Too many levels of symbolic links

Solutions for failing apt-key

Hint: if your system or package registry is heavily damaged , you might manually search for the .deb packages and install them

Solution 1: Coreutils reinstallation

If you see /usr/bin/touch exists but not /bin/touch,

Installing the latter using sudo apt-get install --reinstall coreutils might help.

Solution 2: GPG reinstallation

Your GPG installation might be updated or outdated

sudo apt reinstall gpg
sudo ldconfig $(which /usr/bin/gpg)

References

apt-key deprecation screenshot

Licensed under CC BY-NC-SA 4.0
      ...