Skip to content

apt – no public key error

by mat on May 17th, 2009

If you add a new repository to apt (/etc/apt/sources.list) you may get the following error when running ‘sudo apt-get update':

Reading package lists… Done
W: There is no public key available for the following key IDs:
[Key]
W: You may want to run apt-get update to correct these problems

As you probably already guessed, running ‘sudo apt-get update’ will result in exactly the same problem. This is because the new repository’s key needs to verified. This is done by the following:

gpg –keyserver subkeys.pgp.net –recv [Key]
gpg –export [Key] | sudo apt-key add –

replace [Key] with the key you want to add

This can also be made slightly easier by using a bash variable:

$1=[key]
gpg –keyserver subkeys.pgp.net –recv $1
gpg –export $1 | sudo apt-key add –

replace [Key] with the key you want to add

or as a bash script:

#!/bin/sh
gpg –keyserver subkeys.pgp.net –recv $1
gpg –export $1 | sudo apt-key add -

ran by the following:

./key [key]

replace [Key] with the key you want to add
which then you could place in /bin so you could simply run

Script can be downloaded here

One Comment
  1. After checking out a handful of the blog articles on your
    web site, I seriously appreciate your way of writing
    a blog. I saved as a favorite it to my bookmark site
    list and will be checking back in the near future. Please check out my web site too
    and let me know how you feel.

Leave a Reply

Note: I am currently writing my thesis so probably wont have time to reply to your comment
Note: XHTML is allowed. Your email address will never be published.

Subscribe to this comment feed via RSS