Saturday, February 4, 2012

GitHub How To

Playing with GitHub for almost one week finally I am having Git repo running and up on my Server..Below is the how to 

Check for SSH keys. Have an existing key pair? You can skip to Step 4.
First, we need to check for existing ssh keys on your computer:

$ cd ~/.sshChecks to see if there is a directory named ".ssh" in your user directory
If it says “No such file or directory“ skip to step 3. Otherwise continue to step 2.

Backup and remove existing SSH keys.
Since there is already an SSH directory you’ll want to back the old one up and remove it:

$ lsLists all the subdirectories in the current directory
config id_rsa known_hosts
$ mkdir key_backupmakes a subdirectory called "key_backup" in the current directory
$ cp id_rsa* key_backupCopies the id_rsa and files into key_backup
$ rm id_rsa*Deletes the id_rsa and files
Generate a new SSH key.
To generate a new SSH key, enter the code below. We want the default settings so when asked to enter a file in which to save the key, just press enter.

$ ssh-keygen -t rsa -C ""Creates a new ssh key using the provided email
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/your_user_directory/.ssh/id_rsa):<press enter>
Now you need to enter a passphrase.

Why do passphrases matter?

Enter passphrase (empty for no passphrase):<enter a passphrase>
Enter same passphrase again:<enter passphrase again>
Which should give you something like this:

Your identification has been saved in /Users/your_user_directory/.ssh/id_rsa.
Your public key has been saved in /Users/your_user_directory/.ssh/
The key fingerprint is:
The key's randomart image is:
+--[ RSA 2048]----+
|     .+   +      |
|       = o O .   |
|        = * *    |
|       o = +     |
|      o S .      |
|     o o =       |
|      o . E      |
|                 |
|                 |
Add your SSH key to GitHub.
On the GitHub site Click “Account Settings” > Click “SSH Public Keys” > Click “Add another public key”

Open the file with a text editor (Notepad, TextEdit, or gedit will do just fine). This is your public SSH key. You may need turn on “view hidden files” to find it because the .ssh directory is hidden. It’s important you copy your SSH key exactly as it is written without adding any newlines or whitespace. Now paste it into the “Key” field.


No comments: