How to Fix "Authentication Failure" Error in Linux Package Manager
The "Authentication failure" error in Linux package managers means the system cannot verify the digital signature of a repository or package. This is a security feature that prevents installing untrusted software. Here is how to fix authentication issues.
Fix 1: Add the Missing GPG Key
If the error mentions a missing GPG key or "NO_PUBKEY", you need to add the repository GPG key. The error message includes a key ID. Add it with sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys KEYID. On newer Ubuntu versions, use sudo gpg --keyserver keyserver.ubuntu.com --recv KEYID && gpg --export KEYID | sudo tee /usr/share/keyrings/keyname.gpg.
Fix 2: Update Expired GPG Keys
GPG keys can expire. If the error says the key is expired, you need to renew it. Remove the old key with sudo apt-key del KEYID, then add the updated key from the repository maintainer website. Some repositories provide a package that updates the key automatically, like sudo apt install google-chrome-stable for Chrome repository keys.
Fix 3: Fix Repository Authentication for PPAs
PPAs often cause authentication errors after Ubuntu upgrades. Remove the problematic PPA with sudo add-apt-repository --remove ppa:name, then add it again with sudo add-apt-repository ppa:name. This reinstalls the GPG key. If the PPA is no longer maintained, remove it permanently.
Fix 4: Bypass Authentication (Not Recommended)
If you trust a repository but authentication keeps failing, you can bypass it temporarily. Add --allow-unauthenticated to your apt command: sudo apt install packagename --allow-unauthenticated. This is not recommended for security reasons and should only be used as a temporary workaround until you fix the GPG key issue.