Generate an SSH key pair – Windows

SSH is the secure shell program for connecting to remote servers. It’s also used as a transport mechanism for Git and many other tools. Part of how SSH works is based on public key cryptography, in which you have a private key accessible only to you, and a corresponding public key that you can share with anyone.

Warning: If anything doesn’t work as shown, please get in touch with the instructor right away with the details. Precise output, error messages and screen-shots will help us diagnose the problem!
  1. From the Windows start menu, select All Programs » Git » Git Bash. It will open a command line (terminal) window.

    Git bash command line

    Git bash command line

  2. At the bash prompt ($), type the following command and press enter:

    ssh-keygen

    It should produce output like the following. You will have to press enter three more times: once to use the default file name, and twice to enter an empty passphrase. Your fingerprint, ID, and “randomart” will differ from mine, of course.

    Output of ssh-keygen

    Output of ssh-keygen

  3. Now we need to tell git who you are. It will tag each change you commit with your name and email address. Enter these two commands at the git bash prompt, substituting your actual name and email between the quotes:

    git config --global user.name "YOUR FULL NAME"
    git config --global user.email "YOUR EMAIL ADDRESS"
  4. Finally, type the following command at the bash prompt:

    notepad .ssh/id_rsa.pub

    The notepad window will contain ssh-rsa followed by a long code. This is your public key. Select all (control-A), then copy (control-C).

    The next step depends on which course or project you are taking.

    1. If we are using my git@liucs.net server, just paste the key into an email to , along with your course number and name. You’ll have to wait for a response from me before using your git account. You may close the notepad window now.

    2. If we are using GitHub, log in to https://github.com/ in your browser and select Account Settings in the upper right. Then, in the section SSH Keys, you’ll find a button Add SSH key. Paste your public key into the Key section, and give it whatever title you want. Push the green button to accept.

      You may close the notepad window now.