Having a GPG error with apt-get?

No replies
agentgates
Offline
Joined: 02/06/2015

I've seen a couple of topics users reporting issues with GPG errors after running apt-get, especially when Trisquel was installed from Ubuntu by the trisquelize.sh script. /* the GPG tranquilizer :) */

The error message used to be something like this:

W: GPG error: http://archive.trisquel.info belenos InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY B4EFB9F38D8AEBF1
W: GPG error: http://archive.trisquel.info belenos-updates InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY B4EFB9F38D8AEBF1
W: GPG error: http://archive.trisquel.info belenos-security InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY B4EFB9F38D8AEBF1

I made a very simple script (apt-gpgfix.sh) based upon dpkg-reconfigure that can be used for any Debian-like distro though. I put it here, so next time I can find it too. :)

#!/bin/bash

. /etc/os-release

if [ ! $ID_LIKE = "debian" ]
then
echo "This script is for Debian, Ubuntu or other GNU/Linux systems that are based upon the apt package manager."
echo "Should you have GPG issues with the package manager on your system, please read upon the manual of your distribution"
fi

KEYRING_DIR=/var/lib/apt/keyrings
KEYRING_FILE=$ID-archive-keyring.gpg
KEYRING=$KEYRING_DIR/$KEYRING_FILE

echo Distribution: $PRETTY_NAME
echo Checking your keyring file: $KEYRING
if [ -f $KEYRING ]
then
if [ -w $KEYRING ]
then
echo "File exist and permission granted"
else
echo "Incorrect owner, group or permissions"
chown root:root $KEYRING
chmod 644 $KEYRING
echo "Appropriate owner, group and permissions have been restored"
fi
else
echo "File does not exist"
echo "Reconfiguring corresponding package..."
dpkg-reconfigure $ID-keyring
fi

#------------------------------------------------

After this try 'apt-get update' to see if it reoccurs.