GPG

2020/06/29 by jean tran

Install GPG

Generate a GPG Key

  1. Run the following command:

gpg --full-gen-key
  1. A prompt ask you to choose between 1-4 key type:

Please select what kind of key you want:
   (1) RSA and RSA (default)
   (2) DSA and Elgamal
   (3) DSA (sign only)
   (4) RSA (sign only)
Your selection? 1
  1. It is recommended to choose at least 4096:

RSA keys may be between 1024 and 4096 bits long.
What keysize do you want? (2048) 4096
Requested keysize is 4096 bits
  1. Specify GPG key expiration:

Please specify how long the key should be valid.
         0 = key does not expire
      <n>  = key expires in n days
      <n>w = key expires in n weeks
      <n>m = key expires in n months
      <n>y = key expires in n years
Key is valid for? (0) 0
Key does not expire at all
  1. Asking for confirmation (y/N):

  1. Double checking your info to validate or edit:

  1. Listing GPG Keys:

It will prompt information such as the following:

  1. Export public key ID

Copy the value equivalent of BC4F4B77228120E9 (replace your key ID as listed on step6)

Signing git commits

  1. Add the ID to your Git configuration file config or .gitconfig (example: BC4F4B77228120E9):

  1. Commit can be signed by adding the following -S flag

  1. Case if you don't want to bother with -S flag

Tips & Tricks

For OSX add the following command on your .<type>rc file. (.bashrc | .zshrc)

Last updated

Was this helpful?