9

After installing MS VS Code and doing sudo apt update. an error appeared.

Err:4 https://packages.microsoft.com/repos/code stable InRelease                                                      
  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY EB3E94ADBE1229CF

after reading package lists, there is a follow up GPG Error

W: GPG error: https://packages.microsoft.com/repos/code stable InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY EB3E94ADBE1229CF
E: The repository 'https://packages.microsoft.com/repos/code stable InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.

So far I am using vscode with no issues and vscode is running fine with Python and a few other languages. I can say it didn't affect the software/application itself. However I still find the error a bit annoying when doing sudo apt-get update. Is there anyway to solve this or at least remove this error from coming up every time I do sudo apt-get update?

other additional information:

OS: Ubuntu 22.04.1 LTS x86_64 Jammy Jellyfish

Shell: bash 5.1.16

David DE
  • 2,316
Dreac Leoson
  • 101
  • 1
  • 1
  • 4

2 Answers2

7

You can re-signing the key with this commands:

wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > packages.microsoft.gpg
sudo install -D -o root -g root -m 644 packages.microsoft.gpg /etc/apt/keyrings/packages.microsoft.gpg
rm -f packages.microsoft.gpg

Reference: VSCode Installation on Debian and Ubuntu based distributions

0

This error occurs because Ubuntu's APT package manager cannot verify the Microsoft repository due to a missing GPG key. You can fix this by adding the correct public key and updating repository list. To do that follow the following steps,

  1. Download and Install the Microsoft GPG key
wget -qO - https://packages.microsoft.com/keys/microsoft.asc | sudo gpg --dearmor -o /usr/share/keyrings/microsoft.gpg
  1. Update the Microsoft Repository List Update the repository reference to use the new key.
echo "deb [signed-by=/usr/share/keyrings/microsoft.gpg] https://packages.microsoft.com/repos/code stable main" | sudo tee /etc/apt/sources.list.d/vscode.list
  1. Update and Upgrade Packages
sudo apt update && sudo apt upgrade -y

If you are still fave the issue, remove old key and try to adding manually.

sudo rm /etc/apt/sources.list.d/vscode.list
echo "deb [signed-by=/usr/share/keyrings/microsoft.gpg] https://packages.microsoft.com/repos/code stable main" | sudo tee /etc/apt/sources.list.d/vscode.list
sudo apt update