Let's suppose you have added a key using apt-key. For example, you might have been installing Grafana and ran the following commands.
$ sudo apt-get install -y apt-transport-https $ sudo apt-get install -y software-properties-common wget $ wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add - $ sudo add-apt-repository "deb https://packages.grafana.com/oss/deb stable main" $ sudo apt-get update $ sudo apt-get install grafana
We can now see the keys we added by listing the keys using the apt-key list command.
$ apt-key list /etc/apt/trusted.gpg -------------------- pub rsa2048 2017-01-24 [SC] 4E40 DDF6 D76E 284A 4A67 80E4 8C8C 34C5 2409 8CB6 uid [ unknown] Grafana <firstname.lastname@example.org> sub rsa2048 2017-01-24 [E]
Now we want to delete the key from our trusted list. We can delete the key by using the key ID found in the above output and the apt-key del command. Note that the key ID is 10 bytes - so only take the first half of the second line of pub.
$ apt-key del 4E40 DDF6 D76E 284A 4A67 OK
The key is now deleted. We can verify by listing our keys again.
$ apt-key list
If we want, we can also check the repository which was added.
$ cat /etc/apt/sources.list deb https://packages.grafana.com/enterprise/deb stable main
To delete the repository, open the file in a text editor and delete the relevant line.
Questions? Email email@example.com