Skip to content

Instantly share code, notes, and snippets.

@ad2ien
Created January 18, 2023 14:29
Show Gist options
  • Save ad2ien/790fed69bd79f5753032eb676d27f55d to your computer and use it in GitHub Desktop.
Save ad2ien/790fed69bd79f5753032eb676d27f55d to your computer and use it in GitHub Desktop.
configure git and github to sign commits
#! /bin/bash
set -euo pipefail
# Interactively generate a new GPG key
gpg --default-new-key-algo rsa4096 --gen-key
# Get key id
KEY=$(gpg --list-secret-keys --keyid-format=long \
| grep '^sec.*$' \
| tr -s ' ' \
| cut -d ' ' -f 2 \
| cut -d '/' -f 2)
# Configure git client
git config --global user.signingkey $KEY
git config --global commit.gpgsign true
echo "Your public key (to give to github) :"
echo ""
gpg --armor --export $KEY
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment