Click here to Skip to main content
13,596,097 members
Click here to Skip to main content
Add your own
alternative version

Tagged as


2 bookmarked
Posted 24 Feb 2011
Licenced CPOL

Issues in Generating RSA Key Pair for GitHub

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

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 ( 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 which were created. The next step would be to add the public key to your github account. Here, you will have to open the 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’ (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”.


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


About the Author

Mark Vinod Sinnathamby
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 Feel free to email or message him anytime and strike up a conversation.

You may also be interested in...

Comments and Discussions

-- There are no messages in this forum --
Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web01-2016 | 2.8.180621.3 | Last Updated 25 Feb 2011
Article Copyright 2011 by Mark Vinod Sinnathamby
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid