How to Configure Git SSH for Pageant Authentication

The other day, I had trouble cloning a GitHub repository using PowerShell. I use SourceTree as my Git GUI, and it was working fine. However, cloning via the command line just wasn't working.

I eventually discovered that my system Git was using a different SSH application than SourceTree. I was able to clone the repository using SourceTree's MinGW terminal.

From the StackOverflow article linked below, I learned that I should set the PuTTY Plink application as Git's default SSH app. So, I went to Windows 11 Settings -> System -> About -> Advanced System Settings -> Environment Variables. There, I added a new system environment variable by clicking the "New" button.

The Environment Variables window

Inserting a new system variable

Next, I verified that the environment variable was set by opening a new (important!) PowerShell window and running the $Env:GIT_SSH command. The result confirmed that it was working.

Checking that the environment variable has been set via PowerShell

Now, I should have been able to add keys via Pageant and use them with Git. Pageant is another PuTTY app for managing SSH keys, and SourceTree also uses it for authentication. Here's a screenshot of the app:

A screenshot of the Pageant app

I navigated to my <user>\source\repos directory in PowerShell and tried to clone a private repository. It worked! Here's a screenshot of the result:

Cloning a repository in PowerShell

Using Pageant with Git via the command line requires some setup, but it's definitely worth it.

Sources: