Score:0

How to use gpg without --keyserver (which is deprecated too, just like apt-key)

jp flag

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

Score:0
jp flag

Read further, as the sentence on the gpg(1) continues...

--keyserver name

This option is deprecated - please use the --keyserver in ‘dirmngr.conf’ instead.

If you are running GnuPG with sudo i.e. as root, you should configure it in /root/.gnupg/dirmngr.conf, otherwise in ~/.gnupg/dirmngr.conf:

keyserver hkps://keyserver.ubuntu.com
no-use-tor

The additional no-use-tor prevents GnuPG from trying to use Tor for the key retrieval, which is its default operation.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.