The background
For some time now, apt-key
warn users with deprecated messages like this one:
use of apt-key is deprecated, except for the use of apt-key del in maintainer scripts to remove existing keys from the main keyring
There is a lot of documentation online (on SE network and elsewhere) about "fixing" those apt-key
warning by using gpg
directly. For instance:
curl -sS <https://example.com/key/repo-key.gpg> | sudo apt-key add -
can be replaced by
curl -sS <https://example.com/key/repo-key.gpg> | gpg --dearmor | sudo tee /usr/share/keyrings/<repo>-archive-keyring.gpg
in order to avoid deprecated errors.
The issue
In Debian, sometimes we need to add Ubuntu PPA. We usually do something like:
sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com XXXXXX
that can become either of:
# something like
gpg --recv-keys --keyserver keyserver.ubuntu.com XXXXXX
# or something like
sudo gpg --no-default-keyring \
--keyring /usr/share/keyrings/<myrepository>-archive-keyring.gpg \
--keyserver <hkp://keyserver.ubuntu.com:80> \
--recv-keys <fingerprint>
but there is a catch: gpg --keyserver
option is also deprecated!
--keyserver name
This option is deprecated
The question
How can we add an Ubuntu PPA on Debian 11 without using the deprecated gpg --keyserver
option?
If that matter, my purpose is using it inside a script or an automation tool like ansible, so I would prefer to avoid manuals or GUI steps.
See also / Related
- https://dev.gnupg.org/T4512
- https://unix.stackexchange.com/questions/679495/now-that-apt-key-is-deprecated-how-do-you-add-an-ubuntu-ppa-as-a-debian-apt-sou <= in my opinion this is not a duplicate, as the most rated answer doesn't provide a solution for the gpg
--keyserver
deprecation - https://www.digitalocean.com/community/tutorials/how-to-handle-apt-key-and-add-apt-repository-deprecation-using-gpg-to-add-external-repositories-on-ubuntu-22-04
- https://itsfoss.com/apt-key-deprecated/
- https://www.linuxuprising.com/2021/01/apt-key-is-deprecated-how-to-add.html
- https://askubuntu.com/questions/1286545/what-commands-exactly-should-replace-the-deprecated-apt-key
- https://askubuntu.com/questions/1328806/how-to-solve-apt-key-deprecated