Windows git SSH authentication to GitHub

Installing Git for Windows

  1. Download git for windows
  2. Run the downloaded installer and pay attention to the following settings
  3. You may prefer installing the git context menu, but I like to keep things simple so I just unchecked it


  4. Choose “Use Git from the Windows command prompt”


  5. Choose “Checkout windows-style, commit Unix-style line endings”


Installing SSH tools

The most common SSH windows utilities are the ones coming with Putty.

Downloading Putty binaries

First you need to go to Putty binaries repository and download the following resources:

  1. puttygen.exe
  2. plink.exe
  3. pageant.exe

Generating SSH keys

If you don’t have a SSH public/private key pair you can generate it using the puttygen utility.

From now on I’ll use %USER_HOME% whenever I refer to your Windows user home folder, which depending on your Windows version may be located in:



Windows XP

C:\Documents and Settings\vlad

Windows 7 and later


You need to create a %USER_HOME%.ssh folder to store your SSH private key.

mkdir .ssh
  1. Open puttygen and click Generate


  2. Copy the public key to clipboard
  3. Go to your GitHub account, open the Account settings menu and navigate to the SSH Keys section. There you need to paste your public key


  4. Add a strong key passphrase for securing your private key usage and click “Save the private key”. You need to save it to the %USER_HOME%\.ssh folder.

    You should now have a %USER_HOME%\.ssh\github-rsa.ppk file.

Setting up the SSH agent

  1. Create a shortcut of pagent.exe and save it in the Startup folder. (e.g. For WindowsXp %USER_HOME%%\%Start Menu\Programs\Startup).

    In Windows 10, you can access the Startup folder associated to your user account under this path:

    Windows\Start Menu\Programs\Startup

    Make sure the shortcut’s target contains the path to your key as well.

    C:\Putty\pageant.exe %USER_HOME%\.ssh\github-rsa.ppk

  2. Run pagent and it should go to your System Tray
  3. Double-click the pagent System Tray icon


  4. Make sure the %USER_HOME%\.ssh\github-rsa.ppk private key is listed
  5. Go to environment variables and add the GIT_SSH variable to reference the plink.exe system path.


Testing time

First you need to establish a Plink connection, to make sure the SSH authentication works:

D:\kits\Putty>plink.exe -v
Looking up host ""
Connecting to port 22
Server version: SSH-2.0-libssh-0.6.0
Using SSH protocol version 2
We claim version: SSH-2.0-PuTTY_Release_0.63
Using Diffie-Hellman with standard group "group14"
Doing Diffie-Hellman key exchange with hash SHA-1
Host key fingerprint is:
ssh-rsa 2048 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48
Initialised AES-256 SDCTR client->server encryption
Initialised HMAC-SHA-256 client->server MAC algorithm
Initialised AES-256 SDCTR server->client encryption
Initialised HMAC-SHA-256 server->client MAC algorithm
Pageant is running. Requesting keys.
Pageant has 1 SSH-2 keys
Using username "git".
Trying Pageant key #0
Authenticating with public key "artsoft96" from agent
Sending Pageant's response
Access granted
Opening session as main channel
Opened main channel
Server refused to allocate pty
Started a shell/command
Server sent command exit status 1
Hi vladmihalcea! You've successfully authenticated, but GitHub does not provide shell access.
Disconnected: All channels closed

Now clone one of your GitHub repositories and play with git. You shouldn’t be asked for your username/password.

D:\vlad\GitHub>git clone
Cloning into 'db-util'...
remote: Reusing existing pack: 213, done.
remote: Total 213 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (213/213), 150.94 KiB | 97.00 KiB/s, done.
Resolving deltas: 100% (86/86), done.
Checking connectivity... done.
D:\vlad\GitHub>cd db-util
D:\vlad\GitHub\db-util>git commit -a -m "Change developer id to author"
[master 93ee2bf] Change developer id to author
 1 file changed, 1 insertion(+), 1 deletion(-)
D:\vlad\GitHub\db-util>git push
Counting objects: 7, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 337 bytes | 0 bytes/s, done.
Total 3 (delta 2), reused 0 (delta 0)
   21e9c0e..93ee2bf  master -> master

Subscribe to our Newsletter

* indicates required
10 000 readers have found this blog worth following!

If you subscribe to my newsletter, you'll get:
  • A free sample of my Video Course about running Integration tests at warp-speed using Docker and tmpfs
  • 3 chapters from my book, High-Performance Java Persistence, 
  • a 10% discount coupon for my book. 
Get the most out of your persistence layer!

9 thoughts on “Windows git SSH authentication to GitHub

  1. Hi,
    We have generated private keys through puttygen so as you mentioned we can access git through pageant and plink.

    But how can we use same ppk to access git through Linux ad we don’t have plink and pagent ?.

    We are working to automate a build process for which we need all code to be cloned on unix

    1. As the article title states, this set up is for Windows, not Linux. On Linux, it’s actually simpler since you should have the ssh service already installed. The keys go into /home/${user.account}/.ssh/id_rsa and you should also create the authorized_keys. Just read a tutorial for setting up ssh on Linux and you’ll know what to do.

Leave a Reply

Your email address will not be published. Required fields are marked *