Set up SSH & GitHub

In order for us to work with GitHub during class, you'll need to authenticate the computer you'll use during class with GitHub. Follow these steps:

Before you generate a new SSH Key

Check to see if you already have an .ssh directory in your home directory. If this is the first time working with SSH keys, you probably don’t a .ssh directory. Note: Directories that start with a dot are usually hidden.

  1. Open Git Bash (or Terminal if on a Mac)
  2. Make sure you’re in your home directory.
    • cd ~/ (change to your home directory)
      Note: The ~ is the last key to the left of the numbers at the top of your keyboard. Press shift + ~ to get the character.
    • ls -a (to list directories and files including hidden ones)
    If you do not have an .ssh directory, you can skip to the Generating a new SSH Key section just below.
  3. If you have an .ssh directory, change into that directory to see if you already have SSH keys. Type the following two commands
    • cd .ssh (switch into the .ssh directory)
    • ls (list files in that directory)
  4. If you have an SSH key in the directory, you can use one of those keys for this class, so you can skip ahead to copying the key to GitHub. Or you can use the instructions below to generate a new key. Just use a different name when you save the key in step 2 and anywhere else where you reference this key. (e.g. id_rsa_gitclass)

Generate a new SSH key

Taken from
  1. Open Git Bash (or Terminal if on Mac). Paste the text below, substituting in your email address. This creates a new ssh key, using the provided email as a label.
    ssh-keygen -t rsa -b 4096 -C ""
    > Generating public/private rsa key pair.
  2. When you're prompted to "Enter a file in which to save the key," press Enter.
    This accepts the default file location.
    Enter a file in which to save the key (/c/Users/you/.ssh/id_rsa): [Press enter]
  3. At the prompt, type a secure passphrase, and then write it down so you'll remember it - this passphrase as you will be asked to enter it often. NOTE: When you type your passphrase, you won't see the characters appear on screen, nor will you see the cursor move. This is due to security.
    • Enter passphrase (empty for no passphrase): [Type a passphrase]
    • Enter same passphrase again: [Type passphrase again]

Add your SSH key to the SSH-Agent

Taken from

check for existing SSH keys and make sure you’ve generated a new key.

  1. Ensure the ssh-agent is running. It most likely is. Type:
    eval $(ssh-agent -s)
    Response should look something like:
    > Agent pid 59566
    If so, it's running.
  2. Add your SSH private key to the ssh-agent. Type:
  3. ssh-add ~/.ssh/id_rsa

Copy Your SSH Key to add it to GitHub

First, you need a Github account. If you already have one, skip down to item 7.

  1. Go to
  2. Create an account
    • Select the free account unless you want a paid account
  3. Once you have your Github account set up, go to your account settings, in the upper-right hand corner of the page and choose Settings
  4. On the left-side menu, choose SSH and GPG keys
  5. Click the green ‘New SSH Key’ button
  6. Type a title for your key. It can be anything you want to help identify this key. (Project name, computer name where key lives, etc.)
  7. Copy the SSH key you created:
  8. Note: when you run this command, nothing will seem to change on your computer. What this command does is copy the text of the key to your clipboard, which will enable you to paste it to GitHub.

  9. Paste your SSH Key into the Key section of Github and Save. Your key should end with the email address you entered when you first created your key
Test your SSH Key In Git Bash or Terminal if on Mac), type:
ssh -T
You’ll receive a response:
> The authenticity of host ‘ . . . . .. RSA key fingerprint is . . . . Are you sure you want to continue connection (yes/no)?
Type: yes
You should receive a response:
> Hi You’ve successfully authenticated, but Github does not provide shell access.
And that's it! You are ready for class. If you have any questions, please contact us.