Skip to content

Instantly share code, notes, and snippets.

@Fleshgrinder
Last active May 17, 2021 10:00
Show Gist options
  • Save Fleshgrinder/5906809e5fdb3b4bd90076891d34cc2f to your computer and use it in GitHub Desktop.
Save Fleshgrinder/5906809e5fdb3b4bd90076891d34cc2f to your computer and use it in GitHub Desktop.
Create GPG Key for GitHub Commit Signing
#!/bin/sh
set -eu
#
# Commands for generating a new GPG key for GitHub commit signing.
#
# https://help.github.com/articles/generating-a-new-gpg-key/
#
gpg --full-gen-key
# 1. 1
# 2. 4096
# 3. 1y
# 4. Richard Fussenegger
# 5. [email protected]
# 6. GitHub
# 7. ****************************************
id=$(gpg --list-keys --keyid-format LONG | grep -Eoe'4096R/([A-Z0-9]+)' -m1 --color=never | cut -d/ -f2)
gpg --armor --export $id >public.key
gpg --armor --export-secret-key $id >private.key
printf 'Add %s as signingkey to your global .gitconfig file\n' $id
@jowagner
Copy link

--full-gen-key was needed on my system to be asked about the key size

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment