Skip to content

Instantly share code, notes, and snippets.

@kylejeske
Created April 3, 2019 11:13
Show Gist options
  • Save kylejeske/45df7ddab8e370464484696350a95f02 to your computer and use it in GitHub Desktop.
Save kylejeske/45df7ddab8e370464484696350a95f02 to your computer and use it in GitHub Desktop.
Quick and easy: grab your GPG key
#!/bin/bash
printf "%s\n%s\n" "Note: This program assumes there is only 1 key (sec) assigned to a GPG Public key. If there is a secondary (ssb) assigned, this program WILL NOT work."
# Signing Commits and Assigning GPG Key to GitHub Account
# https://help.github.com/en/articles/signing-commits
# https://help.github.com/en/articles/associating-an-email-with-your-gpg-key
$(gpg --update-trustdb 2> 1)
# Fetch list-secret-keys & public key
gpgkey=$(gpg --list-secret-keys --keyid-format LONG | awk 'NR==3' | cut -b 15-30)
gpgpub=$(gpg --armor --export $gpgkey)
# Print it to the screen
printf "Your GPG Key is: %s\n" $gpgkey
# Export Public GPG Key, Output it to the screen at the same time store it to local .gpg folder as pubkey.pgpkey
echo "$gpgpub" | tee -i -p --output-error=exit-nopipe .secring.pgpkey 2> 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment