~ Mayank Johri’s Tips ~

April 9, 2007

Adding Public keys for apt-get

Filed under: Linux, Packaging — mayankjohri @ 1:49 pm

When one adds a new repositry in sources.list file then there is a high possibility that we face the following error when `apt-get update` command is executed

————————- Error —————–

W: GPG error: http://edevelop.org unstable Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 7E5D69A103CA4243
W: GPG error: http://ftp.debian-unofficial.org sarge Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY D5642BC86823D007
W: There are no public key available for the following key IDs:
B5D0C804ADB11277
W: You may want to run apt-get update to correct these problems
————————————————-

To resolve this issue i have created a script which when provided the KeyID will download the key and add it to your key ring.

---------------------------------- Script ------------------------

gpg --keyserver subkeys.pgp.net --recv-keys $1
gpg --armor --export $1 | apt-key add -
——————————————————————

1 Comment »

  1. The second line of your little script needs a sudo for apt-key to work and thus should read:

    gpg –armor –export $1 | sudo apt-key add -

    Also, if a line was added before the first line as follows

    #/bin/sh

    then things would work better. I named the script file “key-import”. Now the script will be recognised by Linux as a script. Of course you would need to do “chmod +r key-import” to make it executable.

    Now you may call the script by issuing the command “./key-import D018A4CE” (of course replacing the actual key with the last 8 characters of the key that apt-get could not find.

    Lastly you may move the script to a location that is in your path environment variable.

    me@host:~$ env | grep PATH
    PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games

    So I moved my script as follows:

    me@host:~$ sudo mv key-import /usr/local/bin/

    Now I can issue the command “key-import” from anywhere on my machine.

    Comment by Lifeboy — November 16, 2009 @ 7:15 am | Reply


RSS feed for comments on this post. TrackBack URI

Leave a comment

Blog at WordPress.com.