Skip to content

Instantly share code, notes, and snippets.

@codedeep79
Last active December 29, 2025 20:18
Show Gist options
  • Select an option

  • Save codedeep79/49ac6e9d30785e2284e3761d7d65f829 to your computer and use it in GitHub Desktop.

Select an option

Save codedeep79/49ac6e9d30785e2284e3761d7d65f829 to your computer and use it in GitHub Desktop.
Install Visual Studio Code in Ubuntu

Code

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

@lance2k
Copy link

lance2k commented Jul 2, 2025

apt-key is deprecated, use gpg instead. Here's the script

sudo apt-get install wget gpg
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
echo "deb [arch=amd64,arm64,armhf signed-by=/etc/apt/keyrings/packages.microsoft.gpg] https://packages.microsoft.com/repos/code stable main" |sudo tee /etc/apt/sources.list.d/vscode.list > /dev/null
rm -f packages.microsoft.gpg

Source: https://code.visualstudio.com/docs/setup/linux#_install-vs-code-on-linux

@schoenid
Copy link

@lance2k

sudo apt-get install wget gpg
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
echo "deb [arch=amd64,arm64,armhf signed-by=/etc/apt/keyrings/packages.microsoft.gpg] https://packages.microsoft.com/repos/code stable main" |sudo tee /etc/apt/sources.list.d/vscode.list > /dev/null
rm -f packages.microsoft.gpg

This does not work.
The public key is not available.
/usr/share/keyrings/microsoft.gpg exists.

Commands:
sudo add-apt-repository -y "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main"
sudo apt update

Output:

OK:1 http://ch.archive.ubuntu.com/ubuntu noble InRelease
Holen:2 http://ch.archive.ubuntu.com/ubuntu noble-updates InRelease [126 kB]                                                                               
Holen:3 http://ch.archive.ubuntu.com/ubuntu noble-backports InRelease [126 kB]                                                                             
OK:4 https://dl.winehq.org/wine-builds/ubuntu noble InRelease                                                                                              
Holen:5 https://packages.microsoft.com/repos/vscode stable InRelease [3.594 B]                                                                             
OK:6 https://deb.opera.com/opera-stable stable InRelease                                                                                                   
OK:7 https://download.virtualbox.org/virtualbox/debian noble InRelease                                                                                     
OK:8 http://archive.ubuntu.com/ubuntu noble InRelease                                                                                   
OK:9 http://security.ubuntu.com/ubuntu noble-security InRelease           
OK:10 http://archive.ubuntu.com/ubuntu noble-updates InRelease
OK:11 https://ppa.launchpadcontent.net/mediaelch/mediaelch-stable/ubuntu noble InRelease
Holen:12 http://ch.archive.ubuntu.com/ubuntu noble-updates/main amd64 Components [175 kB]
OK:13 https://ppa.launchpadcontent.net/mozillateam/ppa/ubuntu noble InRelease
Holen:14 http://ch.archive.ubuntu.com/ubuntu noble-updates/restricted amd64 Components [212 B]
Holen:15 http://ch.archive.ubuntu.com/ubuntu noble-updates/universe amd64 Components [378 kB]
Holen:16 http://ch.archive.ubuntu.com/ubuntu noble-updates/multiverse amd64 Components [940 B]
Holen:17 http://ch.archive.ubuntu.com/ubuntu noble-backports/main amd64 Components [7.324 B]
Holen:18 http://ch.archive.ubuntu.com/ubuntu noble-backports/restricted amd64 Components [216 B]
Holen:19 http://ch.archive.ubuntu.com/ubuntu noble-backports/universe amd64 Components [10,5 kB]
Holen:20 http://ch.archive.ubuntu.com/ubuntu noble-backports/multiverse amd64 Components [212 B]
Fehl:5 https://packages.microsoft.com/repos/vscode stable InRelease
  Die folgenden Signaturen konnten nicht überprüft werden, weil ihr öffentlicher Schlüssel nicht verfügbar ist: NO_PUBKEY EB3E94ADBE1229CF
Paketlisten werden gelesen… Fertig
W: GPG-Fehler: https://packages.microsoft.com/repos/vscode stable InRelease: Die folgenden Signaturen konnten nicht überprüft werden, weil ihr öffentlicher Schlüssel nicht verfügbar ist: NO_PUBKEY EB3E94ADBE1229CF
E: Das Depot »https://packages.microsoft.com/repos/vscode stable InRelease« ist nicht signiert.
N: Eine Aktualisierung von solch einem Depot kann nicht auf eine sichere Art durchgeführt werden, daher ist es standardmäßig deaktiviert.
N: Weitere Details zur Erzeugung von Paketdepots sowie zu deren Benutzerkonfiguration finden Sie in der Handbuchseite apt-secure(8).

How to get it?

@schoenid
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment