15 September 2015

PPA: NO_PUBKEY C2518248EEA14886

I faced the following error in Ubuntu 15.04 when trying to: sudo apt-get update

GPG error: http://ppa.launchpad.net vivid Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY C2518248EEA14886
 
Googling, there are several solutions for it, but none worked.
Only a old script that is in a couple of Ubuntu forums:

http://ubuntuforums.org/archive/index.php/t-2257304.html





Script:

#!/bin/sh
# This script adds PPA keys to the primary keyring in /etc/apt/trusted.gpg
# thus getting around the GPG limit of 40 keyrings.
# WARNING: It's only intended as the last resort measure.
# Rather than using it, reduce your use of PPAs.
set -e

keyserver=http://keyserver.ubuntu.com:11371
launchpadapi=https://launchpad.net/api/1.0

[ -r /etc/lsb-release ] && . /etc/lsb-release ||
{ echo Cannot read /etc/lsb-release >&2; exit 1;}

[ Ubuntu = "$DISTRIB_ID" ] ||
{ echo This script is supposed to run on Ubuntu >&2; exit 2;}

[ -n "$DISTRIB_CODENAME" ] && codename=$DISTRIB_CODENAME ||
{ echo Cannot determine installed Ubuntu release >&2; exit 2;}
release=$DISTRIB_RELEASE

usage() {
# Parameter: $1 - error message
<<! cat >&2
$1
Usage: sudo $0
Example: sudo $0 $codename
!
exit 3
}

[ 0 = `id -u` ] || usage "Please run with sudo"



if [ -x /usr/bin/ubuntu-distro-info ]
then
codenames=`/usr/bin/ubuntu-distro-info --all | tr '\n' \|`
eval \
case \$1 in \
"$codenames$codename"') codename=$1;;
*) usage "Wrong release name: $1";;' \
esac
else
[ 12 -le "${release%%.*}" ] &&
<<! cat >&2
This script works best with package 'distro-info' installed.

Consider installing distro-info with
sudo apt-get install distro-info

Continuing execution anyway

!

case $1 in
lucid|precise|trusty|utopic|vivid|$codename) codename=$1;;
*) usage "Wrong release name: $1";;
esac
fi

echo "Release: $codename"
echo Please wait...

tempfile() {
# Parameters: $1 - variable to hold the file name
# $2 - short file content description
local tmp
if tmp=`mktemp`
then
eval "$1='$tmp'"
currenttrap="${currenttrap}rm -f -- '$tmp';"
trap "$currenttrap" EXIT
else
echo "Cannot create temporary file for $2" >&2
exit 2
fi
}

tempfile sources 'APT sources'
tempfile fingerprints 'key fingerprints'
tempfile key 'signing key'

sourcelist=/etc/apt/sources.list
eval $(apt-config shell sourcelist Dir::Etc::SourceList/f)
sourceparts=/etc/apt/sources.list.d/
eval $(apt-config shell sourceparts Dir::Etc::SourceParts/d)
grep -hs '^[^#]' "$sourcelist" "$sourceparts"*.list > "$sources" ||:
grep -q '^Types:' "$sources" && {
echo "This script doesn't work with RFC822-style sources.list" >&2; exit 2
}

for ppaowner in $(
awk -F/ '/^deb[ \t]+.*ppa\.launchpad.*[ \t]+'$codename'/{print$4}' \
"$sources"
)
do
wget -qO- "$launchpadapi/~$ppaowner/ppas" |
awk -F'": "|"}' -v'RS="?, "' '/key_fingerprint/{print $2}' |
sort -u >> "$fingerprints"
done
for fingerprint in `sort -u "$fingerprints"`
do
wget -qO- "$keyserver/pks/lookup?op=get&search=0x$fingerprint" |
sed '/-BEGIN/,/-END/!d' > "$key"
if test "$fingerprint" = "$(
apt-key adv --with-colons --with-fingerprint "$key" |
awk -F: '/^fpr/{print $10}'
)"
then
apt-key add "$key"
else
<<! cat - "$key" >&2
Key rejected: retrieved key doesn't match the fingerprint!

Fingerprint: $fingerprint

Retrieved key:
$(apt-key adv --with-fingerprint "$key")
================================================== ========
!
fi
done

rm -f -- "$sources" "$fingerprints" "$key"
trap - EXIT

No comments :

My Blog List

Blog Archive

There was an error in this gadget

Disclaimer

The views expressed on this blog are my own and do not necessarily reflect the views of Oracle.