Score:0

How do I correctly setup a 3rd party repository with a 3rd party key without adding it to the global GPG keyring if I only have their keyid?

in flag

I have a 3rd party software that is installed from their own repository and requires a custom key configured. Instead of adding their key to the global keyring, how do I correctly setup the key to be used only for that repository?

Typical error message would look like this:

The following signatures couldn't be verified because the public key is not available: NO_PUBKEY D208507CA14F4FCA

Nelson avatar
in flag
This was derived from https://askubuntu.com/a/1307181/451170 but I didn't have means to download the key directly, so had to figure out how to interact with the `keyserver` to get said key and deal with all the issues around `GPG`
Score:0
in flag

The keyserver.ubuntu.com can be used to retrieve the key, but you must manually confirm that the key is correct before proceeding:

enter image description here

sudo -H gpg --keyserver keyserver.ubuntu.com --recv-keys D208507CA14F4FCA

This command puts the key in your global keyring, and is an intermediate step to export it. The key will be removed at a later step.

-H is needed to handle permissions issue regarding sudo and the HOME directory

Next is a sequence of commands to export the keyring

sudo -H gpg --export --output erlang.gpg D208507CA14F4FCA
mkdir -p /usr/local/share/keyrings
mv ./erlang.gpg /usr/local/share/keyrings/

And then remove the key from the keyring

sudo -H gpg --batch --yes --delete-key D208507CA14F4FCA

Create a subdirectory for sources.list and add the new config to it:

mkdir -p /etc/apt/sources.list.d
echo "deb [signed-by=/usr/local/share/keyrings/erlang.gpg] https://packages.erlang-solutions.com/ubuntu $(lsb_release -s -c) contrib" > /etc/apt/sources.list.d/erlang.list

Note that add-apt-repository doesn't currently support the [signed-by] option

This process sets up the key for just that repository, limited the risk of a compromised 3rd party key from affecting unrelated repositories.

fuzzy drawings avatar
tj flag
You can shorten the process to just three steps: Create directory for keyring: `sudo mkdir -p /usr/local/share/keyrings`, add keyring to directory: `sudo gpg --no-default-keyring --keyring /usr/local/share/keyrings/erlang.gpg --keyserver keyserver.ubuntu.com --recv-keys D208507CA14F4FCA`, then add the repository to apt sources: `echo "deb [signed-by=/usr/local/share/keyrings/erlang.gpg] https://packages.erlang-solutions.com/ubuntu $(lsb_release -s -c) contrib" | sudo tee /etc/apt/sources.list.d/erlang.list`
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.