Using SSH with git and Github in Windows

Is handy to use SSH while connecting to git, for better security and the advantage of not having to type passwords at every remote operations.

Here the instruction on how to set it up for Windows:

Generate the ssh key

  1. using the command prompt, go to %Git folder%\bin (usually C:\Program Files (x86)\Git\bin or C:\Program Files\Git\bin)
  2. generate the key pair using ssh-keygen, leave the key name as default

Upload the key to github

  1. Go to %USERPROFILE%\.ssh
  2. open the file and copy the content
  3. go to your account in github, and under the SSH Keys tab, enter a new key. Paste your public key and give it a friendly name

Add keys to GitHub

Set up ssh for git

  1. Copy the path of the ssh.exe executable under your \bin folder
  2. Create a new environment variable called GIT_SSH and set it to the path of the ssh.exe GIT_SSH environment variable


  1. Now just clone your repository using the SSH link, rather than the http(s) ones.
  2. If everything was setup correctly you shouldn’t be requested a username or password.
  3. The first time you clone, SSH will ask you to confirm the ssh fingerprint of the remote server Git with SSH


Other git hosts have support for SSH. If you use Stash for example, just copy and paste your content into a new SSH key under your account preferences. Add keys to Stash