My step by step guide

Linux

1. Installing Kleopatra + GPG

On Debian/Ubuntu:

Open your terminal and paste the following:

sudo apt update
sudo apt install kleopatra gnupg2 -y

For Arch-based systems: sudo pacman -S kleopatra gnupg
For Fedora: sudo dnf install kleopatra gnupg2

2. Verify GPG Works

Check if GPG is installed correctly:

gpg --version

Should show version info like:

  • gpg (GnuPG) 2.4.4 version number
  • Home: /home/username/.gnupg installment location

3. Create a GPG Key

Launch Kleopatra or use terminal:

GUI (Kleopatra):

  • Open Kleopatra
  • Click File > New Certificate
  • Follow the wizard to create a personal OpenPGP key

Terminal:

gpg --full-generate-key

Choose:

  • Key type: 1 (default)
  • Key size: 4096
  • Expiration: your choice (e.g. 1y)
  • Name/email/comment as prompted

Then list the key:

gpg --list-secret-keys --keyid-format=long

Look for the key ID after sec (e.g. rsa4096/YOURKEYID)

4. Add GPG Key to GitHub

A. Export your public key:

gpg --armor --export YOURKEYID

Copy the entire output (starts with like -----BEGIN PGP PUBLIC KEY BLOCK-----)

B. Add to GitHub:

  1. Go to GitHub GPG Settings
  2. Click New GPG key
  3. Paste the key and click Add GPG Key
  4. Confirm with your GitHub password if prompted

5. Tell Git to Use Your GPG Key

git config --global user.signingkey YOURKEYID
git config --global commit.gpgsign true

(YOURKEYID should be your key id, and not the word YOURKEYID)

Also tell Git which GPG program to use:

git config --global gpg.program gpg

6. Set Up in VS Code

Option A: Using GUI

  1. Open VS Code
  2. Go to Settings (Ctrl+,)
  3. Search for GPG
  4. Enable Git › Enable Commit Signing

Option B: Manually edit settings.json

Open via Command Palette (Ctrl+Shift+P → Preferences: Open Settings (JSON)):

{
  "git.enableCommitSigning": true
}

7. Fix: gpg: skipped "yourID": No secret key

If you get:

Git: gpg: skipped "yourID": No secret key

It usually means the key isn’t loaded or you generated it with another user. Run:

gpg --list-secret-keys --keyid-format=long

Confirm the ID matches git config --global user.signingkey. If not, correct it.

If using gpg2, make sure Git is pointing to it:

git config --global gpg.program $(which gpg)

Also ensure gpg-agent is running. If not:

gpgconf --launch gpg-agent

8. Optional: Autostart Kleopatra

To make Kleopatra start on boot:

  1. Open your file manager
  2. Go to ~/.config/autostart/
    • Create the folder if it doesn’t exist
  3. Create a file kleopatra.desktop with:
[Desktop Entry]
Type=Application
Exec=kleopatra
Hidden=false
NoDisplay=false
X-GNOME-Autostart-enabled=true
Name=Kleopatra
  1. Save and reboot or log out/in to test

Windows

  1. Installing Kleopatra
      1. go to de download and download the latest version
    1. click on Check integrity
    2. scroll down to SHA256 checksums
    3. now open powershell
    4. type Get-FileHash
    5. Drag your download into the powershell, this is mine: Get-FileHash C:\Users\Gebruiker\Downloads\gpg4win-4.2.0.exe, this will look different for newer versions
    6. press Enter
    7. Check if the hash is the same as on the website, if not, try again or with another version. Otherwise you risk installing a tinkererd version, like malware. (If the letters are upper/lower cased incorrectly, that doesn’t matter)
      • Easiest way to check if it is the same is by using Ctrl+F in your browser
    8. double click the file to install
  2. How to add to github:
    • this document should explain the steps
    • If you cant figure it out, here is a step by step guide:
      1. In the upper-right corner of any page, click your profile photo, then click Settings
      2. In the “Access” section of the sidebar, click  SSH and GPG keys.
      3. Next to the “GPG keys” header, click New GPG key.
      4. In the “Title” field, type a name for your GPG key.
      5. In the “Key” field, paste the GPG key you copied when you generated your GPG key.
      6. Click Add GPG key.
      7. To confirm the action, authenticate to your GitHub account.
  3. tell git you want to use a gpg key:
    • github docs
    • keep in mind: you need to run commands in git bash , not in cmd, but if nothing happens in git bash, try cmd
  4. how to add to vscode:
    • put the following in your vscode settings.json: "git.enableCommitSigning": true or Open the settings, search for “gpg” and check the box “Enables commit signing with GPG”
    • this article explains it. (you can start at Set up VS Code)
  5. If you get an error with committing Git: gpg: skipped "yourID": No secret key:
    • put git config --global gpg.program "C:\Program Files (x86)\GnuPG\bin\gpg.exe" in your console
    • or follow this guide

You also might want to add Kleopatra to startup to avoid having to wait minutes for it to startup when wanting to commit:

  1. press Win to enter search
  2. type “kleopatra”
  3. klick open file location
  4. copy the shortcut to kleopatra
  5. find the startup folder
  6. paste the shortcut here.