90

I added a key like this:

wget -q -O - https://jenkins-ci.org/debian/jenkins-ci.org.key | sudo apt-key add -
sudo sh -c 'echo deb http://pkg.jenkins-ci.org/debian binary/ > /etc/apt/sources.list.d/jenkins.list'

Now I want to remove this key. How can I do that? I don't know where it got added and how does it look like.

When I do sudo apt-key list it prints out few things on the console. Not sure which one is related to what I did above?

david@machine:~$ sudo apt-key list
/etc/apt/trusted.gpg
--------------------
pub   1024D/437D05B5 2004-09-12
uid                  Ubuntu Archive Automatic Signing Key <[email protected]>
sub   2048g/79164387 2004-09-12

pub   1024D/FBB75451 2004-12-30
uid                  Ubuntu CD Image Automatic Signing Key <[email protected]>

pub   4096R/C0B21F32 2012-05-11
uid                  Ubuntu Archive Automatic Signing Key (2012) <[email protected]>

pub   4096R/EFE21092 2012-05-11
uid                  Ubuntu CD Image Automatic Signing Key (2012) <[email protected]>

pub   1024D/D50582E6 2009-02-01
uid                  Kohsuke Kawaguchi <[email protected]>
uid                  Kohsuke Kawaguchi <[email protected]>
uid                  [jpeg image of size 3704]
sub   2048g/10AF40FE 2009-02-01

/etc/apt/trusted.gpg.d//pubring.gpg
-----------------------------------
pub   2048R/06634014 2013-01-26
uid                  OSP Team <[email protected]>
sub   2048R/732F28E7 2013-01-26
1

3 Answers 3

105

apt-key add adds a key to /etc/apt/trusted.gpg by default.

These keys are from Ubuntu repositories:

pub   1024D/437D05B5 2004-09-12
uid                  Ubuntu Archive Automatic Signing Key <[email protected]>
sub   2048g/79164387 2004-09-12

pub   1024D/FBB75451 2004-12-30
uid                  Ubuntu CD Image Automatic Signing Key <[email protected]>

pub   4096R/C0B21F32 2012-05-11
uid                  Ubuntu Archive Automatic Signing Key (2012) <[email protected]>

pub   4096R/EFE21092 2012-05-11
uid                  Ubuntu CD Image Automatic Signing Key (2012) <[email protected]>

Then you're left only with:

pub   1024D/D50582E6 2009-02-01
uid                  Kohsuke Kawaguchi <[email protected]>
uid                  Kohsuke Kawaguchi <[email protected]>
uid                  [jpeg image of size 3704]
sub   2048g/10AF40FE 2009-02-01

Remove it by running:

sudo apt-key del D50582E6

If you really want to make sure you're removing the right key, you could add the key again to a new keyring:

wget -q -O - https://jenkins-ci.org/debian/jenkins-ci.org.key | sudo apt-key --keyring /tmp/test add -

Then list its contents:

sudo apt-key --keyring /tmp/test list

Then you'll see the key you want to remove.

4
  • 84
    if you are wondering what is key, use last 8 letters together from the last two blocks out of ten blocks, like D38B4796 from EB4C 1BFD 4F04 2F6D DDCC EC91 7721 F63B D38B 4796
    – Midhun KM
    Jan 31, 2019 at 7:20
  • 3
    and if you prefer to copy and paste spaces are allowed inside quotes sudo apt-key del 'D38B 4796' Mar 2, 2022 at 14:39
  • sudo apt-key del "EB4C 1BFD 4F04 2F6D DDCC EC91 7721 F63B D38B 4796" would also work.
    – philburns
    Aug 21, 2023 at 15:25
  • On Ubuntu 23 you'll get this error: Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)).
    – Raleigh L.
    Oct 14, 2023 at 21:52
11

You can also directly remove key using

$ sudo apt-key list | grep 'teejee'

You will get

/etc/apt/trusted.gpg.d/teejee2008-ppa.gpg

Then,

$ sudo rm /etc/apt/trusted.gpg.d/teejee2008-ppa.gpg

Just Test again with $ sudo apt-key list | grep 'teejee'

6
  • 2
    askubuntu.com is not like a traditional forum, it is a community curated question and answer site. New good answers are encouraged, even on old questions. Answers are better when they explain the commands used in them. And show both a general form and the form suitable for the question. It is also courteous to include references/acknowledgement of any sources. Such as the comment on one of the other answers. From Review
    – J. Starnes
    Dec 21, 2017 at 8:59
  • 2
    This doesn't answer the question at all. Oct 3, 2018 at 20:40
  • @RussBateman now please give me up-vote. Thank You. Oct 10, 2018 at 6:48
  • I'm not the one that down-voted your answer, but I've up-voted with the edit certainly. Oct 10, 2018 at 13:55
  • Sorry mate. I was unaware of that. Oct 11, 2018 at 4:03
10

Open the software center, go to "Edit" → "Software Sources ..." → "Other Software" and you see a "Remove" button.

3
  • 2
    Well, I have Ubuntu machine which only has command line stuff. No UI stuff at all.
    – arsenal
    Apr 3, 2015 at 18:24
  • sudo add-apt-repository --remove ppa:the/ppa
    – UTF-8
    Apr 3, 2015 at 18:27
  • hmm, what will be my ppa. I don't know much about these stuff. Is it there in the two command which I executed?
    – arsenal
    Apr 3, 2015 at 18:28

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