GIT on the surface : part-I Adding ssh keys

GIT, one of the fastest *distributed* versioning system, (thats a different thing  that I have worked only on  GIT)  but a lot data floating over the net says that.

We all know how much GIT helps us for our projects.  I cann’t forget the moments when my programs works just fine (especially when I program embedded systems )and after a little modification they stops working right.  And git just captures those fine working moments for us. I was a fan for git just for that.  But later on when started with open source and contribuitions,  GIT exceeded the expectations.  Branching, merging all were just awesome to work with.

Here I will be just explaining the ssh-key generation for Github.  Adding multiple keys to work on the repos from your different systems.

ssh-keygen is the command or the program which generates, manages and converts authentication keys for ssh. It can create RSA keys for use by SSH protocol version 1 and RSA or DSA keys for use by SSH protocol version 2.

-t option tells about the type of key to be generated, by default ssh-keygen will generate an RSA key for use in SSH protocol 2 connections.

-f option specifies the file name of the key file., by default if we press enter only, it will take the default file name only..

Syntax goes like this:

$ ssh-keygen -t ‘rsa’  -f “my_location” -C “”

Generating public/private rsa key pair.
Enter file in which to save the key (/home/beyond/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Passphrases do not match. Try again.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/beyond/.ssh/id_rsa.
Your public key has been saved in /home/beyond/.ssh/
The key fingerprint is:
The key’s randomart image is:
+–[ RSA 2048]—-+
|. E . |
|o oo. |
|o…=.. |
|.*.+.o . . |
|. B.. o S |
| . . + + . |
| . + . |
| . |
| |

Now since we have made a key already, so we must have got the public and the private keys in out specified folder or the default folder.  Now one has to add the keys to the required place so as to get access.  Lets have an example with Github


On the website of the github just after the creation of account and a repo, one can simply go to the Account settings of the repo and then to SSH keys in the side portion add up a public key.

Now to add the public key, one must be careful while copying and pasting because it is utterly sensitive to new line characters and all.  So better we use any program for it like Xclip or something.  Its my favorite because it is command line based 😉

So, we can simply use Xclip like this:

$xcli -sel mytext < ~/.ssh/

where, -sel is for selection and mytext is the temp. name for this selection which is actually redirectred from the text of our pub file.  Now, the clipboard is filled up with that public file Exactly as needed.

We just only need to paste this into the ADD ssh key tab at Github site. and we are done.

Now, for testing if everything has gone right we need to ssh into the github account by giving commands

$ssh -T -vg

ssh_github2where, -T is just for disabling the tty allocatiion, and -v is for verbose output.  It doesn’t look good till we see what is actually happening at the backend.

The authenticity of host ‘ (*.*.*.*)’ can’t be established.
# RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
# Are you sure you want to continue connecting (yes/no)?

and finally a line like

Hi beyondszine! <whatever your username is> You’ve successfully authenticated, but GitHub does not provide shell access.

Woops!! we got confirmed connection with Github.


Leave a Reply

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