Created
September 27, 2022 14:07
-
-
Save rlespinasse/3b59bfcf52671a912e52d6f44516cec1 to your computer and use it in GitHub Desktop.
Enable SSH-signed commit/tag on git
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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