How do I fix invalid or corrupted gpg keys?

Hello! I will preface this by saying that I’m a total noob at linux and that this is my first ever post on here. Any help I receive will be appreciated.

The problem:

When I’m trying to install things from the AUR, I get the error " invalid or corrupted package (PGP signat
ure)" I’m currently trying to install Librewolf and the VIM package, but I don’t think that’s relevant.

I’ve been looking up on this problem quite extensively (that takes some time because I’m a noob), and it seems to be relatively common, although the fixes I’ve come across and tried, don’t work for me

I have tried the following to purge my keys and then tried to re-acquire them

sudo rm -r /etc/pacman.d/gnupg

This gives me the error “rm: cannot remove ‘/etc/pacman.d/gnupg/S.gpg-agent.extra’: No such file or directory”

I suspect that this may be the main problem here? Because every other fix seems to be dependent on removing existing keys first, which I am unable to do. Whats going on here?

The following commands I enter into the terminal are:

sudo pacman -Sy gnupg archlinux-keyring manjaro-keyring
sudo pacman-key --init
sudo pacman-key --populate archlinux manjaro
sudo pacman-key --refresh-keys
sudo pacman -Sc
sudo pacman -Syyu

All of which work as intended

I think that’s all, thanks in advance for any help

Welcome to the forum. It is nice to see that you have looked for solutions, and have explained in detail what you have attempted.

It looks to me as though your problem is specific to the AUR packages you are trying to install. It is always a good idea to check the AUR webpage for your AUR packages, and read the comments. If you are trying to install librewolf-bin, for example:
There is a pinned comment that explains that you will need to import a specific key before installing librewolf-bin.
I am not sure which specific vim package you want to install, but there may be a similar posted solution on its page.

I maybe wrong as I don’t use pacman in Manjaro very often but I’m pretty sure pacman can not install packages from AUR.Have you tried to use pamac.

Errors about Keys

If you get a pgp error with AUR packages - you need to import the signature to your personal keyring

gpg --recv-keys abcd1234

Ah ok I see. Getting that key solved it for me. Thanks a lot. Just out of curiosity, do you know why I was unable to run: sudo rm -r /etc/pacman.d/gnupg ?

Yeah, I was curious about that. I do not have a similar file in my gnupg directory. Maybe the output of

ls -Al /etc/pacman.d/gnupg

could offer some clues.

That gave me the return:

total 32
drwx------ 2 root root 4096 12 feb 20.10 crls.d
-rw-r--r-- 1 root root   17 12 feb 20.10 gpg-agent.conf
-rw-r--r-- 1 root root  141 12 feb 20.10 gpg.conf
-rw-r--r-- 1 root root    0 12 feb 20.10 .gpg-v21-migrated
drwx------ 2 root root 4096 12 feb 20.10 openpgp-revocs.d
drwx------ 2 root root 4096 12 feb 20.10 private-keys-v1.d
-rw-r--r-- 1 root root    0 12 feb 20.10 pubring.gpg
-rw-r--r-- 1 root root 2590 12 feb 20.10 pubring.kbx
-rw-r--r-- 1 root root 1349 12 feb 20.10 pubring.kbx~
srwx------ 1 root root    0 12 feb 20.10 S.dirmngr
-rw------- 1 root root    0 12 feb 20.10 secring.gpg
srwx------ 1 root root    0 12 feb 20.10 S.gpg-agent
srwx------ 1 root root    0 12 feb 20.10 S.gpg-agent.browser
srwx------ 1 root root    0 12 feb 20.10 S.gpg-agent.extra
srwx------ 1 root root    0 12 feb 20.10 S.gpg-agent.ssh
-rw-r--r-- 1 root root 1280 12 feb 20.10 trustdb.gpg

Is that odd? Previously the terminal told me that this doesn’t exist, I must be missing something

Moderator edit: In the future, please use proper formatting: [HowTo] Post command output and file content as formatted text

The rm command initially cleared most of the gnupg directory, but the subsequent pacman-key commands repopulated it, as they are supposed to.

I am not really clear on what the above means, though. That first s indicates that this is a socket (as opposed to a file or directory), but that is about all that I understand. Someone more knowledgeable than me is going to have to chime in.