This document explains how KWallet (KDE's credential manager) works and how Visual Studio Code utilizes it to securely store your passwords, tokens, and session keys on Linux.
KWallet is the central credential management system for the KDE Plasma desktop environment. It provides a secure way to store sensitive information such as:
- Wi-Fi passwords
- Web form passwords
- API tokens (like GitHub or Azure)
- SSH key passphrases
- Apps (Tokens/password)
- Encryption: All data in a wallet is encrypted using Blowfish or GPG.
- Access Control: Applications must request access to the wallet. The first time an app requests a secret, KWallet will ask for your permission.
- Wallets: You can have multiple wallets (e.g., one for work, one for personal), but most users use the default
kdewallet.
VS Code uses a feature called Secret Storage to handle sensitive data like GitHub authentication tokens, Settings Sync credentials, and extension-specific keys.
VS Code doesn't talk to KWallet directly. Instead, it uses a standardized bridge:
- VS Code calls the Secret Service API (a standard Linux D-Bus interface).
- libsecret is the library VS Code uses to communicate with this API.
- KWallet (specifically modern versions using KDE Frameworks 5.97+) implements this Secret Service interface.
- Simply it uses
System APIto call ask theKwallet.
VS Code Secret Storage
├── 1. Action: VS Code needs to save/load a secret (Token/password) (e.g. GitHub Token)
|
├── 2. Internal Engine: Electron requests the "Safe Storage Key" (Perpare the API call)
|
├── 3. Bridge: VS Code calls `libsecret` library
│ └── libsecret sends D-Bus message to `org.freedesktop.secrets` (Send the message to Kmanager to store the data in the KWallet)
|
├── 4. Provider (KWallet): Receives the D-Bus request (VS code request the data from the Kmanager)
│ ├── If Wallet Locked: System prompts user for Master Password (Show a window and ask the user to enter the password)
│ └── If Wallet Unlocked: KWallet accesses "Code Safe Storage" entry (directly give the code)
|
├── 5. Physical Storage: Key is encrypted & saved to disk (~/.local/share/kwalletd/)
|
└── 6. Result: VS Code uses the key to encrypt/decrypt local session data
VS Code typically stores a Safe Storage Key. This key is used by VS Code's internal encryption engine (derived from Chromium/Electron) to encrypt the actual data before it is saved in your user profile.
- KWallet Entry Name: Usually found under a folder named
Secret ServiceorChrome Safe Storage. - Key Label: Often labeled as
Code Safe Storage.
If KWallet is not available or locked:
- Repetitive Logins: VS Code will ask you to sign in to GitHub or your Microsoft account every time you restart the application.
- In-Memory Fallback: Without a persistent "keyring" (like KWallet or GNOME Keyring), VS Code falls back to storing secrets in memory only, which are lost when the app closes.
You can manage your secrets using the KWalletManager application.
- View Secrets: Open KWalletManager -> Open your wallet (
kdewallet) -> Look forSecret Service. - Auto-Unlock: To avoid entering your password every time, ensure your KWallet password matches your Linux login password. Most distributions use
pam_kwalletto unlock the wallet automatically when you log in.
If VS Code fails to save your credentials, try these steps:
Ensure the necessary communication library is installed:
# Arch Linux
sudo pacman -S libsecret
# Ubuntu/Debian
sudo apt install libsecret-1-0You can tell VS Code which password store to use.
- Open VS Code.
- Open the Command Palette (
Ctrl+Shift+P). - Search for "Preferences: Configure Runtime Arguments".
- Add the following line to the
argv.jsonfile:(Note: Even on KDE,"password-store": "gnome-libsecret"
gnome-libsecretis used because it refers to the standard library interface.)
Make sure the wallet is "Enabled" in System Settings -> Security & Privacy -> KDE Wallet.