Skip to content

Create a GPG Key to sign git commits

  • create gpg key:
1
gpg --full-generate-key
  • press enter to choose default setting
  • set bitsize to 4096 and enter further information

  • list all keys to get id of the new one

    1
    gpg --list-secret-keys --keyid-format LONG
    
  • and export with:

    1
    gpg --armor --export $KEY_ID
    

push signing key to yubikey

  • backup secret key first:

    1
    gpg --export-secret-key $KEY_ID > signing_key.asc
    
  • then edit it

    1
    gpg --edit-key $KEY_ID
    
    • move it to yubikey with keytocard
    • select the signing option

sign git commit

  • configure git to use the key

    1
    git config --global user.signingkey $KEY_ID
    
  • sign a commit with git commit -S -m "commit message"