Click here to Skip to main content
15,885,278 members
Articles / RSA

Issues in Generating RSA Key Pair for GitHub

Rate me:
Please Sign up or sign in to vote.
3.00/5 (1 vote)
24 Feb 2011CPOL3 min read 11.6K   2  
Issues in Generating RSA Key Pair for GitHub

Recently, I ran into some problems in creating an RSA key pair which is required by github, before committing or pushing code to the online repository. I had downloaded the Rails installer kit (from here), and was trying my first stab at Ruby and Rails. Creating an open repository in github for pushing code required the creation of an RSA key pair, as described in the help pages. This is necessary as github uses SSH for the transfer of files to and from the local machine.

I had successfully created the RSA public and private keys, but ran into issues when testing whether the connection to the github repository worked, as github was not picking up the correct location of the keys in my local machine. To cut a long story short, the following describes what should be done, to avoid the hassle I went through.

When installing the Rails installer kit, Git is also installed alongside Ruby, the Rails framework, and sqlite. When navigating to the RailsInstaller folder after installation, you will find the bin folder inside the Git folder (/RailsInstaller/Git/Bin/) which contains the tools necessary for creating the RSA key pair. You have to include the Git’s bin location in the PATH environment variable (if it is not automatically configured during installation), in order to easily access the tool set from the command prompt. Also, if the ‘home’ system variable is missing, you will have to create a key ‘home’, which has value ‘C:\

Image 1

After setting the environment variable, I created a folder named “.ssh” in my C drive, and this is where github will look for the public key. Once the folder was ready, I created the key pair using the ‘ssh-keygen’ command. You have to enter the .ssh folder created as the location (watch out for the UNIX style folder location specifier), and id_rsa as the key (file) name. This will create a private key (id_rsa) and a public key (id_rsa.pub) inside the .ssh folder. Also, enter a good pass phrase or hit enter without typing anything for a blank pass phrase (though entering one is recommended):

Image 2

If you navigate inside the .ssh folder created, you would see the two keys, id_rsa and id_rsa.pub which were created. The next step would be to add the public key to your github account. Here, you will have to open the id_rsa.pub file in a text editor, copy the contents without any whitespace or newlines, and paste the contents as described in the “Adding the key to your github account” section in this page.

In order to test if everything went well, you can use the ‘ssh’ command, typing ‘ssh git@github.com’ (as described in the github help page as well) to see if you connect properly. When the prompt asks you whether you want to continue connecting, and you type yes, a ‘successfully authenticated’ message should be displayed:

Image 3

The message shown above means that github properly identified your public key and you can push code using Git, from the local repository to github. Note that none of the above steps will work properly if the ‘home’ system variable does not exist or contain the value ‘C:\’, in order to indicate the home location that github uses to search for the .ssh directory. Since I’ve got my relationship with github stable and secure, my next adventure would be to deploy the Rails application at heroku, which will most likely turn out to be a future blog post. My first attempt at Ruby (and Rails, and Git, and sqlite), and I can safely say, “so far, so good”.

Image 4 Image 5 Image 6 Image 7 Image 8 Image 9 Image 10 Image 11

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Technical Lead Exilesoft
Sri Lanka Sri Lanka
Mark is a Technical Lead at Exilesoft, whose passion lies in coding, mentoring, and fueling technical innovation. In the past, he has worked as a developer for a product engineering company, an ERP/Technical Consultant in a Fortune 500 conglomerate, and also as a senior engineer for a startup in the manufacturing and design space. His current areas of research revolve around Enterprise Architecture, Big Data, NoSQL Technology, and Machine Learning.

In his spare time, Mark experiments with (computer) game design/development, operating system internals, and compiler design. He also discusses and blogs about various topics surrounding software development, computer science, game programming, and mathematics, which can be read at markfaction.wordpress.com. Feel free to email or message him anytime and strike up a conversation.

Comments and Discussions

 
-- There are no messages in this forum --