Something so simple, should never be this difficult. For the mac/osx/linux, this is a no-brainer as it's built right into your OS as a integral part. For windows users, not so lucky
Note: replace all of the usages of spongebob with your actually account name.
Step 1: Install the Git client
Grab git from here http://msysgit.github.io/ (you could probably use another one, but for this post - that's the choice). If you already have it installed, and it is installed in the default location of "C:\Program Files (x86)\Git" - you will want to uninstall it.
Let's create a new home for our application. Use the command line or Explorer, either will get the job done. Navigate to the root C:\ drive and create a new folder, 'opt'. Call it what you want, but try and stick to lower case, alpha characters. Absolutely no spaces (thus the reason for moving it originally).
When you install Git, select the new folder c:\opt\Git. (for the rest of this example, that will be the folder we use - replace those values with whatever you actually use)
Select the middle option, 'Run Git from the Command Line'
Step 2: Environment Variables
The following variables are all configured from the same location. Open your system settings, find the 'Advanced system settings' link and bring up the Systems Properties window.
From here, on the bottom click the 'Environment Variables...' and another window should pop up (big love for the Windows OS ... #dryhumor)
These ARE Case sensitive.
HOME Variable
This one is the only 'User Variable' we'll set. Click the top 'New' button.
Variable Name: HOME
Variable value: c:\Users\spongebob
Save it ...
The next three are System Variables. If you are not an admin, use all User Variables.
GIT_HOME
Click 'New'
Variable Name: GIT_HOME
Variable value: C:\opt\Git
Click 'New'
Variable Name: GIT_SSH
Variable value: %GIT_HOME%\bin\ssh.exe
Scroll down and find the 'Path' entry, select it and click 'Edit...'
In the value box, move the cursor to the very front of the string, do not delete or change any existing values. You will want to add the following (minus quotes) "%GIT_HOME%/bin/;"
for example: if the path looks like this when you start:
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem; ....
it should look like this when click 'OK'
%GIT_HOME%/bin/;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem; ....
Close all of Windows' silly windows and make your way back to the Desktop. Open a command prompt and lets test out our settings. Type in: git and you should see the help instructions.
If you see something like this ... we're in great shape. If not, walk through the instructions, might be missing a semicolon or have an extra white space somewhere.
Step 4: Generate an SSH key
Now to generate a key, open-ssh comes with Git. From the command prompt, enter the following:
ssh-keygen -t rsa
the place you want to save it is in your HOME (the value we used earlier: C:\Users\spongebob) plus .ssh\id_rsa ... the final value should be: C:\Users\spongebob\.ssh\id_rsa
Feel 100% free to rename it to anything you want: github-personal, github, spongebob-github ... etc
This is a personal preference, if you add a pass phrase to your key, every time you use it you will be asked to enter the password. Your call, I don't set one for the key I use for github.
Step 5: Github
From the top right, click your profile window and select 'Settings', from the left, select 'SSH keys' and finally 'Add SSH key'.
In notepad, open the pub file we created earlier. C:\Users\spongebob\.ssh\id_rsa.pub copy it and paste it in. Do not paste the contents of the key without an extension (id_rsa) - that is your private key and you should never share that with anyone.
If your public key is on multiple lines, combine them.
If your key is missing the string 'ssh-rsa' at the beginning, you will need to add that as well. If you try to add the key in Github without the string, it will bark at you.
Step X: (Optional) Add an SSH config file
If you named your key something other than id_rsa, we need to do a little configuration.
Open your favorite text editor, and save the following file: C:\Users\spongebob\.ssh\config
The body of the file should have these values:
Host github.com
Hostname github.com
User git
IdentityFile ~/.ssh/spongebob-id_rsa
Step 6: Put it all together
Now we test it out. Create a project on github called diamond-dave, save it, from the clone area (bottom right) click SSH, then click the button, it should copy the URL to your clipboard.
From the command prompt, type in: git clone git@github.com:spongebob/diamond-dave.git
After the project checks out ... celebrate ... but lets check one last thing.
cd into the project
touch README.md (if you didn't already when you created the project)
open with your favorite editor, add the following.
If you created the file, add this
# Diamond-Dave
If it was already there, add to it
**No more passwords for me!**
Save the file and we have one final task:
enter the following commands:
git add .
git commit -am "pushing with no password"
git push origin master
Enjoy!