Click here to Skip to main content
Click here to Skip to main content

Tagged as

Go to top

Issues in generating RSA key pair for GitHub

, 24 Feb 2011
Rate this:
Please Sign up or sign in to vote.
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 push

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:\’

 

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):

 

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:

 

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”.


License

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

Share

About the Author

Mark Sinnathamby
Software Developer Air Liquide Industrial Services
Singapore Singapore
Mark is a software developer at Air Liquide Industrial Services - Singapore, where he helps Develop, Deploy, and Maintain large scale enterprise applications in the Asia-Pacific region. While his main work experience converges on .Net technologies, he has proficient experience in C++, HTML5/CSS/Javascript Web technologies, mobile development, OpenGL and DirectX API's, as well as a bit of J2EE. He loves to dabble with Game programming in his spare time, and blogs about his development experience at http://markfaction.wordpress.com and http://gamecoderlogic.wordpress.com.
Follow on   Twitter

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Mobile
Web04 | 2.8.140922.1 | Last Updated 25 Feb 2011
Article Copyright 2011 by Mark Sinnathamby
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid