Skip to content

GPG Singing and SSH Signing

SuperBo edited this page Jun 28, 2024 · 5 revisions

In order to sign commit with git, you have 2 options, using GPG key or SSH key. GPG key requires you have GnuPG setup while SSH Key requires you have OpenSSH setup. Usually, setting up OpenSSH is more convenient.

πŸ”‘ SSH Key signing

Ensure you have OpenSSH installed. Then configure your repo as following.

git config commit.gpgsign true
git config gpg.format ssh
# you must set signingkey for ssh signing to work.
git config user.signingkey ~/.ssh/id_ed25519.pub 

Install openssh guide

  • Arch Linux: sudo pacman -S openssh
  • Ubuntu: sudo apt-get install openssh-client
  • Fedora: sudo dnf install openssh-clients
  • Mac: brew install openssh

πŸ”‘ GPG Key signing

Ensure you have GPGme installed. And install a GUI pinentry program, so that it doesn't clear terminal buffer of Neovim GUI. Then configure your repo as folowing

git config commit.gpgsign true
# reset gpg format
git config --unset gpg.format
# Optionally set your gpg key
git config user.signingkey "KeyID"

Install GPGMe guide

Arch Linux

sudo pacman -S gpgme

MacOS

brew install gpgme pinentry-mac
# Set Pinentry
echo "pinentry-program $(which pinentry-mac)" >> ~/.gnupg/gpg-agent.conf

Ubuntu/Debian

sudo apt-get install libgpgme11
# Use gnome3 for pinentry
sudo apt-get install pinentry-gnome3
echo "pinentry-program $(which pinentry-gnome3)" >> ~/.gnupg/gpg-agent.conf
# Usse Qt for pinentry
sudo apt-get install pinentry-qt
echo "pinentry-program $(which pinentry-qt)" >> ~/.gnupg/gpg-agent.conf

Windows

Download and install GPG4Win

Configure GPGme path

If you install GPGme to a directory that isn't included in system path, you have to configure it manually for Fugit2 to load it. Configure it as following

-- Fugit2 setup table
{
  gpgme_path = "<path/to/library/dir>"
}