Replace deprecated apt-key

What does this MR do and why?

Replace deprecated apt-key

apt-key is deprecated by Debian and should no longer be recommended. See https://manpages.debian.org/unstable/apt/apt-key.8.en.html:

apt-key(8) will last be available in Debian 12 and Ubuntu 24.04.

Instead of downloading and adding PGP keys via apt-key add, there are two solutions:

  1. Preferred: download the key into /etc/apt/keyrings/ or if it is part of a package, put it into /usr/share/keyrings/. ASCII-armored files should use the file extension .asc while un-armored (binary) files should use the file extension .gpg Afterwards use deb [ signed-by=…/keyring/… ] https://… in any sources.list file to specifically use that keyring only for that source entry.

  2. Alternatively put the key in /etc/apt/trusted.gpg.d/ using the same extension as noted above. This allows the key to be used to sign any source. As such it is less secure and not recommended by Debian.

Remove the unneeded gpg --dearmor and store and use the ASCII-armored PGP key: This is supported since APT 1.4 from 2017 and got first released for Debian-8-Jessie in 2018, which is now EOL, even for ELTS.

While at it consistently use sudo curl --fail --silent --show-error --output:

  • --fail-with-body stored the HTML error document as the key; afterwards APT becomes very unhappy.
  • curl | tee hides any error from curl, in which case an empty file is created by tee.
  • Add --show-error to see when curl --silent fails to spot errors.

Security consideration: Some people consider sudo curl unsafe. An alternative would be to use something like this everywhere:

(
    tmp=$(mktemp)
    trap 'rm -f "$tmp"' EXIT
    curl --output "$tmp" &&
        sudo install -m 644 "$tmp" /etc/apt/…
)

Closes: #212967 (closed) Signed-off-by: Philipp Hahn p.hahn@avm.de

References

Screenshots or screen recordings

Before After

How to set up and validate locally

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Philipp Hahn

Merge request reports

Loading