Skip to content
Dave Strus edited this page May 25, 2016 · 6 revisions

SSH

I recommend setting up an SSH key to simplify authentication with GitHub and other services.

Check for an existing key

Make sure you're in your home directory. You should be by default, but you can double-check with the "print working directory" command: pwd

$ pwd

You should be in /Users/yourusername. If not, you can switch to that directory with the cd command, passing in the directory you want to switch to. You can always use a tilde (~) as a shortcut for your home directory.

$ cd ~

Check to see if you already have an .ssh key configured:

$ ls ~/.ssh/id_rsa

If it prints /Users/dstrus/.ssh/id_rsa, then you already have an SSH key and can skip to the next page: GitHub.

Generate an SSH key

If you do not have an existing key, run the following command, substituting the email address you used earlier, to create one:

$ ssh-keygen -t rsa -C "youremail@example.com"

It should prompt you for a file name. You can just hit 'enter' to accept the default.

It will then prompt you for a password. You can just hit 'enter' (twice) to not set a passphrase. That compromises your key should anyone gain access to your laptop, but it may be simpler for the sake of this course. It's much safer to use a passphrase when generating a key when you truly want to maximize security.

If all is well, you should see that your identification and your public key have been saved to .ssh/id_rsa and .ssh/id_rsa.pub respectively.

Run the following command to add your new key to the SSH agent on your Mac:

$ ssh-add ~/.ssh/id_rsa

You'll test your new key shortly, but first you'll need to create a GitHub account and add your public key to the account.

Clone this wiki locally