Linux Tutorials

Install Visual Studio Code on Ubuntu 26.04 LTS

Microsoft’s install instructions for Visual Studio Code changed shape between May and November 2026. The one-line vscode.list file and the /etc/apt/keyrings location are gone from the docs, replaced by a deb822 vscode.sources file and a keyring at /usr/share/keyrings/microsoft.gpg. We reinstalled every route on a fresh Ubuntu 26.04 server with VS Code 1.145.2, tested in November 2026, covering the apt repo, the .deb with its preseed, and the snap.

Original content from computingforgeeks.com - post 167457

Two findings shape this guide. The legacy .list format still works on 26.04 with no warning, so an old install keeps updating even though the deb822 form is what the docs teach now. Put both files on one machine and apt throws a wall of configured multiple times warnings until one goes. What follows is the deb822 install with fingerprint verification, the migration for existing installs, and the errors we reproduced.

Every point release since May went to agent features such as remote agents, MCP allowlists, and cron-driven automations. Nothing touched Linux packaging, which is why the May instructions aged on repository format rather than editor features.

Pick the right packaging path

Three routes install VS Code on 26.04. The differences that matter are who ships updates and where the binary lands:

RouteUpdatesWatch out for
Microsoft apt repo (deb822)apt upgrade, same cadence as the rest of the systemAdds a third-party repo and key; mixing with an old .list file triggers duplicate-source warnings
.deb downloadWires the apt repo itself on install, then apt upgradeA 263 MB download on every re-run until the repo takes over
Snap (classic)Automatic, on Canonical’s refresh scheduleBinary at /snap/bin/code, slower cold start, no repo control

For most installs the apt repo is the right answer because the package manager owns the update, the key is verifiable, and the binary lands where desktop integrations expect it. One caveat from the Microsoft docs covers distributions that ship their own code package, such as Pop!_OS, which need a pin in /etc/apt/preferences.d/code or their build wins the resolution. The rest of this guide takes the repo route and covers the two alternatives after it.

Step 1: Install the signing key

Two paths repeat through the install, where the keyring lives and where the source file goes. Set them once so the rest of the steps paste as-is.

export MS_KEYRING="/usr/share/keyrings/microsoft.gpg"
export MS_SOURCE="/etc/apt/sources.list.d/vscode.sources"

Confirm the values stuck before going further:

echo "keyring: ${MS_KEYRING}"
echo "source:  ${MS_SOURCE}"

Apt on 26.04 fetches signed repos natively, so the deb822 format needs no apt-transport-https, and the Microsoft docs no longer list that package. Only wget and gpg are required to fetch and dearmor the key:

sudo apt update
sudo apt install -y wget gpg

Download the armored key and convert it to the binary keyring format apt expects, then make it world-readable so apt can read it during package operations.

wget -qO- https://packages.microsoft.com/keys/microsoft.asc \
  | sudo gpg --dearmor -o "${MS_KEYRING}"
sudo chmod 644 "${MS_KEYRING}"

Verify the key landed correctly against the fingerprint Microsoft publishes. The --show-keys form reads the keyring without importing anything into your own keyring:

gpg --show-keys --with-fingerprint "${MS_KEYRING}"

A matching fingerprint reads BC52 8686 B50D 79E3 39D3 721C EB3E 94AD BE12 29CF. A mismatch means the download was corrupted or intercepted. Delete the keyring and re-fetch from a known-good network before adding any repository that trusts it.

GPG fingerprint verification of the Microsoft VS Code signing key on Ubuntu 26.04

Keep that keyring where it is. Step 2 points the repository at this exact path, and nothing else in the install rewrites it.

Step 2: Add the deb822 source and install

Open the source file. The deb822 stanza replaces the old one-line deb entry, and the Architectures field covers amd64, arm64, and armhf in one file:

sudo vim "${MS_SOURCE}"

Add the following stanza, which matches the one in Microsoft’s Linux setup docs line for line:

Types: deb
URIs: https://packages.microsoft.com/repos/code
Suites: stable
Components: main
Architectures: amd64,arm64,armhf
Signed-By: /usr/share/keyrings/microsoft.gpg

Refresh the package lists and confirm the new repository answers. The InRelease line is the signed metadata fetch and the Packages line is the index for your native architecture:

sudo apt update

Install the editor and stamp the version:

apt update fetching the Microsoft VS Code deb822 repository on Ubuntu 26.04

Expect Get lines on the first fetch after adding the source. Later updates print Hit because the metadata is already cached.

sudo apt install -y code
which code && code --version

VS Code prints the release number, the build commit, and the architecture. The Architectures field in the stanza lists what the repo serves, not what apt downloads, since only the native index fetches unless you add foreign architectures with dpkg --add-architecture. From here, every apt upgrade picks up new VS Code releases automatically because the source file lives in your apt configuration.

code --version output on Ubuntu 26.04 after installing from the Microsoft apt repo

Note the commit in that output, since the snap comparison later in the guide is judged against it.

Step 3: Migrate a legacy vscode.list install

If you installed VS Code from the older instructions, the .list file keeps working. We let apt run against it on a clean 26.04 server and it fetched the repo with no warning at all. The problem is not breakage, it is coexistence. When the .list and the .sources describe the same repository, every apt update prints this:

Warning: Target Packages (main/binary-amd64/Packages) is configured multiple
times in /etc/apt/sources.list.d/vscode.list:1 and /etc/apt/sources.list.d/vscode.sources:1

Migrating is three lines once the deb822 file from Step 2 is in place. Drop the legacy file, then update. The keyring at /etc/apt/keyrings/microsoft.gpg can go too, since the new source no longer references it.

apt warning when vscode.list and vscode.sources describe the same repository on Ubuntu 26.04

Each warning names both files, which is the pairing the removal commands below erase.

sudo rm -f /etc/apt/sources.list.d/vscode.list
sudo rm -f /etc/apt/keyrings/microsoft.gpg
sudo apt update

A clean update afterwards shows a single Hit or Get line for packages.microsoft.com and no warnings. Skip the removal and apt still works, but the warnings repeat on every refresh and bury real problems in the noise.

Step 4: Install the first-run extensions

VS Code is usable the moment it lands, and a few extensions make it useful on a dev box. The CLI installs them without opening the window, which also makes stamping the same set across a fleet trivial:

code --install-extension ms-vscode-remote.remote-ssh
code --install-extension eamodio.gitlens
code --list-extensions

The list output confirms what landed. Remote-SSH pulls in two companions (remote-ssh-edit and the remote explorer) automatically, so four IDs print for two install commands. Add ms-python.python the same way for Python work with interpreter discovery and notebooks, and GitLens layers blame and history on every file you open.

Installing Remote SSH and GitLens extensions from the CLI on Ubuntu 26.04

Both extensions release often, so your install output will show newer versions than the capture.

Step 5: Connect Remote-SSH to a dev server

Remote-SSH is the feature that makes the editor worth its install size on server-heavy stacks. It needs key-based SSH working to the target first. If key setup is still pending, the GitHub CLI cheat sheet covers the token and host steps. Add the host to your SSH config:

vim ~/.ssh/config

Add one block per server you want in the picker:

Host devbox
    HostName 10.0.1.50
    User ubuntu
    IdentityFile ~/.ssh/id_ed25519
    ServerAliveInterval 30

From the command palette, pick Remote-SSH: Connect to Host and choose devbox. The first connection installs a small VS Code Server under ~/.vscode-server/ on the remote, and from then on every file open and every terminal spawn runs on the server while only the UI lives on the laptop. If that server directory ever goes stale after a remote upgrade, remove it and reconnect, and the client reinstalls it.

Alternative: install the .deb with a preseed

Microsoft’s docs now lead with the .deb download, and the package does more than it used to. With one preseed line, it installs non-interactively and wires the repository itself, which makes it the fastest route for scripts and cloud-init:

echo "code code/add-microsoft-repo boolean true" | sudo debconf-set-selections
wget -O /tmp/code.deb https://go.microsoft.com/fwlink/?LinkID=760868
sudo apt install -y /tmp/code.deb

Without the preseed the same install prompts once for whether to add the Microsoft repo in an interactive terminal, and falls back to adding it silently when no terminal is attached. With it, the package postinst writes its own deb822 file at /etc/apt/sources.list.d/vscode.sources and the keyring at /usr/share/keyrings/microsoft.gpg, the same locations Step 1 and Step 2 create by hand, and it deletes a leftover /etc/apt/sources.list.d/vscode.list on the way. The postinst file pins Architectures: amd64 only, and a second debconf knob named code/add-copilot-command now exists alongside the repo toggle. You can check the stored answers any time:

sudo debconf-show code

Our download weighed 263 MB, so the preseed route costs more bandwidth than the repo route on repeat runs. Its value is that a single command both installs the editor and hands the repository to apt from then on.

Non-interactive .deb install of VS Code with the debconf preseed on Ubuntu 26.04

The preseed answers the repo question before apt reaches it, which is why the capture shows Preconfiguring packages and no prompt.

Alternative: install via snap

If third-party apt repos are off the table, the snap is the fallback and it is published in the store by Microsoft itself. Classic confinement is required so the editor can read your project directories:

sudo snap install --classic code
which code && code --version

Our snap carried build commit c4453f8e, identical to the deb from the repo, so freshness is not the trade-off. What changes:

  • Binary location: /snap/bin/code instead of /usr/bin/code, which matters to scripts that hardcode the path.
  • Update cadence: snapd refreshes on its own schedule instead of riding apt upgrade.
  • Cold start: a beat slower on first launch than the deb build.

Mixing the snap and the apt install on one machine is confusing rather than broken. Pick one and stay with it.

Installing VS Code from the snap store and confirming the version on Ubuntu 26.04

The (vscode**) marker in the install line is the store’s verified-publisher badge, and it is what tells you the snap really came from Microsoft. A desktop terminal with unicode fonts renders the same badge as a check mark, so either form means the same thing.

Common errors and what they mean

Error: NO_PUBKEY EB3E94ADBE1229CF and “The repository is not updated”

A wrong Signed-By path looks like this on the apt that ships with 26.04. We pointed the source at a keyring that did not exist and captured the real output:

Warning: An error occurred during the signature verification. The repository
is not updated and the previous index files will be used. OpenPGP signature
verification failed: 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

Read the last 16 hex characters of the NO_PUBKEY value as the tail of Microsoft’s key fingerprint, which tells you apt found a signature but no key to check it against. Check that Signed-By points at the exact path where gpg --dearmor wrote the file, and that the file is mode 644. Note the severity too, since apt words this as a Warning and keeps the previous index files, so installs still work from cache and the failure hides until the next refresh.

Warning: is configured multiple times

Both the legacy .list and the new .sources describe the same repository. Remove the .list as shown in Step 3 and the warnings stop. Nothing is broken in the meantime. Apt fetches the metadata twice and complains about it once per target.

Error: You are trying to start Visual Studio Code as a super user

Run sudo code and the wrapper refuses before anything loads:

You are trying to start Visual Studio Code as a super user which isn't
recommended. If this was intended, please add the argument `--no-sandbox`
and specify an alternate user data directory using the `--user-data-dir` argument.

Open the project as the normal user almost every time, and use sudo from the integrated terminal when a file needs root. When a root editor session is genuinely required, the wrapper names its price, --no-sandbox plus a separate --user-data-dir so the root session does not clobber the regular profile.

Two errors that older VS Code guides still list did not reproduce on current builds. The libxkbfile.so.1 failure came from the deb not declaring its GUI dependencies. Today’s package metadata declares the three GUI libraries as hard dependencies, so a repo install on a server image pulls them itself:

  • libxkbfile1: the keyboard layout library the old error named.
  • libgtk-3-0: the windowing toolkit behind the editor shell.
  • libasound2: the audio backend the desktop build links.

The canberra-gtk-module message never appeared in our headless runs, and it is cosmetic when a desktop session does show it. Installing libcanberra-gtk-module silences it.

Uninstall and rollback

Apt route, including the repository and key that Steps 1 and 2 added:

sudo apt remove --purge -y code
sudo rm -f "${MS_SOURCE}" "${MS_KEYRING}"
rm -rf ~/.vscode ~/.config/Code

Snap route:

sudo snap remove --purge code
rm -rf ~/snap/code

Both routes leave your project directories untouched. Only the editor state under ~/.config/Code and ~/.vscode goes. To finish the workstation, the Node.js install covers npm and pnpm, the Python guide handles venvs, the Go toolchain install wires the workspace layout, and the Docker CE install gives you the dev-container backend. For an editor-adjacent AI workflow, the Claude Code install on 26.04 pairs with the extensions above.

You end up with the full path on current builds, the keyring verified against the published fingerprint, a deb822 source matching the format Microsoft documents, extensions stamped from the CLI, and a migration that retires the legacy file without a reinstall.

Keep reading

Upgrade Ubuntu 24.04 to Ubuntu 26.04 LTS (Step by Step) Ubuntu Upgrade Ubuntu 24.04 to Ubuntu 26.04 LTS (Step by Step) UFW Firewall Commands with Examples on Ubuntu 26.04 / 24.04 Security UFW Firewall Commands with Examples on Ubuntu 26.04 / 24.04 Backup and Restore Linux Systems with Timeshift Debian Backup and Restore Linux Systems with Timeshift Deploy Collabora Online Office on Ubuntu with Let’s Encrypt SSL Cloud Deploy Collabora Online Office on Ubuntu with Let’s Encrypt SSL Install CyberPanel on Ubuntu 26.04 / 24.04 with Let’s Encrypt Ubuntu Install CyberPanel on Ubuntu 26.04 / 24.04 with Let’s Encrypt Convert Video to MP3 on Linux with FFmpeg AlmaLinux Convert Video to MP3 on Linux with FFmpeg

Leave a Comment

Press ESC to close