4

When adding a repository through add-apt-repository a new gpg key will be add.

e,g:

sudo add-apt-repository ppa:some-ppa

You will be asked to press Enter to import the gpg key. I need to get the gpg key for ppa:some-ppa without executing add-apt-repository.

Is it possible to get the gpg key before adding the repository (before executing add-apt-repository) from command line?

7
  • 2
    What PPA are you adding? Please be specific.
    – Terrance
    Commented Jan 31, 2021 at 15:18
  • @Terrance I have edited my question.
    – GAD3R
    Commented Jan 31, 2021 at 15:22
  • You will find the keys usually on the PPA itself under the Technical Details. Example: launchpad.net/~graphics-drivers/+archive/ubuntu/ppa
    – Terrance
    Commented Jan 31, 2021 at 15:37
  • @Terrance Is there a way to get the gpg key from command line?
    – GAD3R
    Commented Jan 31, 2021 at 16:13
  • 1
    @Terrance can you provide an example for "<key>" ?
    – secavfr
    Commented Dec 22, 2022 at 10:32

1 Answer 1

6

Here's a procedure that essentially tries to replicate sudo add-apt-repository ppa:owner/name but lets you do all the steps (including downloading the GPG key) manually:

  1. Go to the page of the owner/name PPA on Launchpad: https://launchpad.net/~owner/+archive/ubuntu/name.

  2. Look for signing key's fingerprint on the page.

    In the page there should be a section "Fingerprint:" with the key fingerprint printed below.

  3. Download the PPA key into a specific directory on your system.

    • Download the key via the URL https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x<fingerprint>, where <fingerprint> is the value you found in step 2.
    • Dearmor the key and put it in /etc/apt/trusted.gpg.d/owner_ubuntu_name.gpg.
  4. Create a file /etc/apt/sources.list.d/owner-ubuntu-name.list with these contents:

    deb http://ppa.launchpad.net/owner/name/ubuntu <codename> main
    

    where <codename> is what lsb_release -sc gives.

  5. Enjoy the new software that the PPA provides!

Example, Safe Eyes (ppa:slgobinath/safeeyes) software

  1. Go to https://launchpad.net/~slgobinath/+archive/ubuntu/safeeyes

  2. As of 7th March 2023 the page says:

    Fingerprint:

    53A5446DABC1B038506E33F5E71C080343BB5214

  3. Run:

    curl -S "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x53A5446DABC1B038506E33F5E71C080343BB5214" \
      | sudo gpg --batch --yes --dearmor --output "/etc/apt/trusted.gpg.d/slgobinath_ubuntu_safeeyes.gpg"
    
  4. Run:

    echo "deb https://ppa.launchpadcontent.net/slgobinath/safeeyes/ubuntu $(lsb_release -sc) main" \
      | sudo tee /etc/apt/sources.list.d/slgobinath-ubuntu-safeeyes.list
    
  5. Run sudo apt update && sudo apt install safeeyes and enjoy your new software!

1
  • It seems at least on Ubuntu 22.04 you can skip the dearmor step, if you save the keyserver's response to /etc/apt/trusted.gpg.d/somename.asc (note the .asc extension) Commented Aug 16, 2023 at 8:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .