GPG key with Git

Hi all,

Hows going on? Hope fine. Today I had a rush of work, though I manage some time to upgrade my skills with Git. As now my dream is contribute any opensource project (basically linux). So I need a GPG key to gain trust of other people around over my code. I searched for sometime and give some shoot and finally I can commit one with GPG key over git.

Here is how I did that,

First I need to make a GPG private key by follows,

1. Open a terminal.
2. type in the following code:

gpg --gen-key

3. Then enter a “1” – to create a standard DSA/ElGamal key. Press Enter.
4. Type in 1024. Press Enter.
5. Type in 0. Press Enter.
6. Enter a y. Press Enter.
7. Type in your Real Name. Press Enter.
8. Type in your REAL email address. Press Enter.
9. Type in Your First Name, followed by “‘s PGP Key”. Press Enter. (Better skip this by Enter blank)
10. Type O. Press Enter. It will now create your Key.
11. You will have to give it a “Pass Phrase” … usually a short sentence or phrase (You need to remember it like password!!!).

Then make a public key over your private key,

1. Open a terminal.
2. Type in the following code:

gpg --export -a "email" > public.key

3. Open a nautilus window.
4. Find the file “public.key” in your home directory.
5. Right click on the file, left click on open in text editor.
6. Press CTRL+A, then CTRL+C (Select All, Copy)
7. Open http://pgp.mit.edu in a browser window.
8. In the box under the label, “Submit a key” – right click in the box and then left click on paste.
9. Click on “Submit this key to the keyserver!”
10. Go back to http://pgp.mit.edu
11. Type in your name in the Search String box.
12. You will get your details.

Now we need to configure our git with this key so that we can commit our change with GPG key. For this do the followings,

gpg --list-keys

whcih will give you your GPG key details as,

pub 1024D/123ABC89 2012-12-08
uid Tapan Kumer Das

Here 123ABC89 is your ID. Now copy the ID to git configure with,

git config --global user.signingkey 123ABC89

Now you are able to sign your commits by using the option -S as,

git commit -a -S -m "GPG Commit"

With the following command you can check your log details.

git log --show-signature

This is all for now, hope to share my upcoming knowledge… Have a nice day.

(Visited 38 times, 1 visits today)

Leave a comment

Your email address will not be published. Required fields are marked *