Redhat YUM – How to Automatically Run nogpgcheck on Yum Install

redhatyum

I'm taking over a big project. 5 engineers worked on it for some years, but they are gone now. There are multiple install scripts, and they are very complicated. Somewhere inside of those scripts, they have commands such as:

yum install postgresql10

Which gives me the error:

Error: Failed to download metadata for repo 'pgdg-common': repomd.xml GPG signature verification error: Bad GPG signature

If I was running this on the command line, I could simply do:

dnf install -y --nogpgcheck  https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm

I ran this command and it worked great.

Here is the problem: the install scripts die when they run into that error. I need to get around that somehow.

Is there a way to get yum to automatically run --nogpgcheck on every call of yum install?

You might think "Just grep the install scripts and then change the individual lines." But I cannot do that because the commands are full of variables and other junk, so I cannot grep for anything as clear and straightforward as "yum install". Some of the install commands are constructed over several lines.

How do I turn off the gpgcheck on all yum calls?

Best Answer

Why you want to disable gpg check by default, GPG check exists with purpose and my suggestion is to not try to skip it, but instead to fix it. And the real answer is yes, you can edit .repo files in yum repo dir /etc/yum.repos.d, for each repo there you have a option gpgcheck=1 just set it to 0 and you should be good to go.

If you want to do it for all, you can do it like so:

sudo sed -i 's/gpgcheck=1/gpgcheck=0/g' *