Skip to content

Instantly share code, notes, and snippets.

@rlespinasse
Created September 27, 2022 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rlespinasse/3b59bfcf52671a912e52d6f44516cec1 to your computer and use it in GitHub Desktop.
Save rlespinasse/3b59bfcf52671a912e52d6f44516cec1 to your computer and use it in GitHub Desktop.
Enable SSH-signed commit/tag on git
#!/usr/bin/env bash
# Get path of ssh key
ssh_pub_path=$(find ~/.ssh/*.pub | fzf -1)
ssh_path=${ssh_pub_path//.pub/}
# Signature par SSH
git config --global gpg.format ssh
# Signature automatique des commits et tags
git config --global commit.gpgsign true
git config --global tag.gpgsign true
# Configuration de la signature
mkdir -p "$HOME/.config/git"
echo "$(cut -d' ' -f3 "$ssh_pub_path") $(cat "$ssh_pub_path")" >"$HOME/.config/git/allowed_signers"
git config --global gpg.ssh.allowedSignersFile "$HOME/.config/git/allowed_signers"
git config --global user.signingKey "$(cat "$ssh_pub_path")"
ssh-add "$ssh_path"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment