Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
In order to push your first commit to the remote Origin you’ll create in step 2, you’ll need to create an SSH key for your account. This helps your computer connect securely to GitHub, and you only need to do it once per computer you want to access the repository from. The GitHub site has a pretty in-depth writeup of how to do this at http://help.github.com/mac-set-up-git/; however, I’ll give you the basic steps here.
In Terminal.app, navigate to your ssh directory using the command:
cd ~/.ssh
Check to see what’s in the directory by using the command:
ls
This will list all the contents of the directory. If you see the filenames id_rsa and id_rsa.pub, those are your current SSH keys; you can skip to 5. If you don’t see them, you want to create a new one. To generate a new SSH key, enter the code:
ssh-keygen -t rsa -C "your_email@youremail.com"
Enter file in which to save the key (/Users/your_user_directory/.ssh/id_rsa):?Now you need to enter a passphrase.
Enter passphrase (empty for no passphrase):<enter a passphrase>Enter same passphrase again:<enter passphrase again>
This should give you a message 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/id_rsa.pub.? The key fingerprint is:?01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db user_name@username.com?
You now want to add this key to your GitHub account.
If you don’t have a GitHub account yet, skip to Step 4: Set Up a GitHub Account for a moment and come back.
To do this, go into the Account Settings page and click the SSH Public Keys tab (see Figure 4-1). Create a new key by pressing the Add a New Key button.
Now you have to get the contents of your actual RSA key. If you have
your Finder set up to show hidden files (this is usually not a good idea,
as it’s easy to accidentally delete things you need), you can navigate
directly to the .ssh directory and open
id_rsa.pub in a text editor like TextWrangler to copy
the key. Personally, I prefer using the command line. Assuming that you’re
still in the ~/.ssh directory (if you aren’t, use
cd ~/.ssh to navigate there now) you can use the
following code to spit out the key:
ls
This spits out the contents of the directory, which should be:
id_rsa id_rsa.pub known_hosts
From there, type the following code:
cat id_rsa.pub
It should spit out a long line of gobbledygook that starts with
ssh-rsa and ends with your email address. Copy all of
it with no lines or extra spaces and paste it into the text box on GitHub,
then click Add Key. Go ahead; I’ll wait.
Once you do that, you should be all set to push and pull
to your GitHub account.