Adding Public keys for apt-get


When one adds a new repository 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 | sudo apt-key add -
——————————————————————

Advertisements

4 thoughts on “Adding Public keys for apt-get

  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.

  2. I like to work with with shell functions and alias, so I have added this:

    addpk () {
    gpg –keyserver subkeys.pgp.net –recv-keys $1
    gpg –armor –export $1 | sudo apt-key add –
    }

  3. You are doing too many steps.

    Just run:
    sudo apt-key adv –keyserver pgp.mit.edu –recv-keys 7E5D69A103CA4243

    That downloads and adds the key

  4. I’ve read several just right stuff here. Certainly worth bookmarking for revisiting.
    I wonder how a lot attempt you place to make such a wonderful informative website.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s