Very first thing you need is the command line tool to generate the keys which you can download from here for your operating system. I advise you to use the latest version whenever possible.
How to generate GPG keys:
- Open terminal
- Considering you are using the latest version of GPG command line, run the below command to generate the GPG key (Keep in mind, it is going to ask multiple questions, answer them truthfully as much as possible) -
gpg --full-generate-key
- Now, very first thing is the Algorithm to generate the GPG key, if you are generating it first time, press Enter to choose the default but if you are generating for any application, choose the algorithm which is supported by your application encryption/decryption logic.
- Based on the algorithm selected, it might ask for the key length, provide the maximum length for better security unless you have some specific requirement to fill.
- Next, To select the validity period, I advise to input "1y" for 1 year but remember you have to rotate the key when it get expire. If this seems like a hassle, choose default by pressing Enter for "No Expiration"
- Verify, all your selections are correct
- Provide your Name, Email ID and Description about key usage
- Most Important - Provide a passphrase for key security, longer the better but DO NOT forget the passphrase, If you forget it, there is NO WAY you can recover, So choose, Wisely
- If all information is accurate, provide input to generate the key.
- (Optional) For better entropy generation, keep moving your mouse when system is trying to generate the key.
- Your GPG key is generated and stored in your home directory (~/.gnupg/pubring.kbx).
- To list all your GPG keys, you can run below command -
gpg --list-keys --keyid-format=long
gpg --gen-revoke KEYID > KEYID.revoke.asc
# Export Public Key gpg --armor --export KEYID > KEYID.pub # Export Secret Key gpg --armor --export-secret-keys KEYID > KEYID.key
# Upload Public key on keyserver/s
gpg --keyserver hkps://keys.openpgp.org --send-key KEYID # or gpg --keyserver https://keyserver.ubuntu.com --send-key KEYID # or gpg --keyserver https://pgp.mit.edu --send-key KEYID
# Search Keys
gpg --keyserver hkps://keys.openpgp.com --search KEYID
# or gpg --keyserver https://keyserver.ubuntu.org --search KEYID
# or gpg --keyserver https://pgp.mit.edu --search KEYID
# Import Keys from file
gpg --import PUBLIC-KEY-FILE
# Import from Keyserver gpg --keyserver https://keys.openpgp.com --recv-keys KEYID
# or gpg --keyserver https://keyserver.ubuntu.org --recv-keys KEYID
# or gpg --keyserver https://pgp.mit.edu --recv-keys KEYID
# List Public Keys in local keyring gpg --list-keys
# List Secret Keys in local keyring gpg --list-secret-keys
In next post, We will learn about Revocation Certificate.
Video:
Like the below page to get the update
Facebook Page Facebook Group Twitter Feed Telegram Group
Facebook Page Facebook Group Twitter Feed Telegram Group
No comments:
Post a Comment