
For Debian testing OS, many people encounter errors while updating the system, such as, missing GPG keys or failed repository updates. Most of the time, this occurs due to outdated repository keys. You can follow this guide to solve such an annoying error.
Common Errors
When running sudo apt update
, you might encounter errors like:
Warning: An error occurred during the signature verification. The repository is not updated and the previous index files will be used.
GPG error: <repository_url> InRelease: Sub-process /usr/bin/sqv returned an error code (1), error message is: Missing key <key_id>, which is needed to verify signature.
or
Warning: Some index files failed to download. They have been ignored, or old ones used instead.
Notice: Missing Signed-By in the sources.list(5) entry for '<repository_url>'
This means the package manager can not verify the integrity of repositories due to missing or incorrect GPG keys.
Fixing the Issue
Such an error simply can go away just by running the following command:
sudo apt update --allow-insecure-repositories
If the error persists, follow the below steps:
sudo rm -f /etc/apt/keyrings/<repository_name>.gpg
sudo mkdir -p /etc/apt/keyrings
curl -fsSL <repository_gpg_key_url> | gpg --dearmor | sudo tee /etc/apt/keyrings/<repository_name>.gpg > /dev/null
echo "deb [signed-by=/etc/apt/keyrings/<repository_name>.gpg] <repository_url> stable main" | sudo tee /etc/apt/sources.list.d/<repository_name>.list
apt update
Example: Fixing the Microsoft Repository Issues
- Remove the outdated Microsoft GPG key
sudo rm -f /etc/apt/keyrings/microsoft.gpg
- Download and add the updated key
sudo mkdir -p /etc/apt/keyrings; curl -fsSL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor | sudo tee /etc/apt/keyrings/microsoft.gpg > /dev/null
- Ensure the repository is correctly formated
echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/microsoft.gpg] https://packages.microsoft.com/repos/code stable main" | sudo tee /etc/apt/sources.list.d/vscode.list
- Final
apt update
If everything runs without errors, your repositories are now correctly configured!