sudo apt update
sudo apt install software-properties-common apt-transport-https wget
wget -q https://packages.microsoft.com/keys/microsoft.asc -O- | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main"
sudo apt update
sudo apt install code
Last active
January 21, 2026 23:40
-
-
Save codedeep79/49ac6e9d30785e2284e3761d7d65f829 to your computer and use it in GitHub Desktop.
Install Visual Studio Code in Ubuntu
wget -q https://packages.microsoft.com/keys/microsoft.asc -O- | sudo apt-key add -is working fine.
It will add microsoft's key to the /etc/apt/trusted.gpg.d directory, which is insecure.
Instead, you should put the microsoft.gpg in a memorable place such as /usr/share/keyrings/ or /etc/apt/keyrings/ and then add Signed-By metadata to your .list or .sources file (whichever you are using).
(The .list and .sources files are located in /etc/apt/sources.list.d/, if you were not aware)
Your vscode.list should look like:
deb [arch=amd64 signed-by=/usr/share/keyrings/microsoft.gpg] https://packages.microsoft.com/repos/vscode stable main
But actually the .sources format is now preferred to the .list format.
Here's what my vscode.sources file looks like:
X-Repolib-Name: microsoft packages VSCode repository
Enabled: yes
Types: deb
URIs: https://packages.microsoft.com/repos/vscode
Suites: stable
Components: main
Architectures: amd64
Signed-By: /usr/share/keyrings/microsoft.gpg
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment

wget -q https://packages.microsoft.com/keys/microsoft.asc -O- | sudo apt-key add -is working fine.