'Using git with ssh-agent on Windows

I'm on Windows. I installed git and posh-git (some helpers for Windows PowerShell). I can add keys with ssh-add and can authenticate with github and my webserver. I can also use git from the PowerShell to interact with my repositories.

But there is one thing I can't do: I use git-plus for the Atom editor. And I don't get it to push to my repo. What is my problem?



Solution 1:[1]

You can get the ssh-agent running using the command that comes with Git for Windows in powershell:

 start-ssh-agent.cmd

That will start up the ssh-agent.

Then you can add your key with

 ssh-add ~/.ssh/namneOfPrivateKey

Found that here: https://docs.microsoft.com/en-us/azure/devops/repos/git/use-ssh-keys-to-authenticate?view=azure-devops

Solution 2:[2]

Since a couple of years, the ssh part has been separated from posh-git, and is now available through posh-sshell.

To install:

PowerShellGet\Install-Module posh-sshell -Scope CurrentUser
PowerShellGet\Install-Module posh-git -Scope CurrentUser

In your ps1 file:

Import-Module posh-git
Import-Module posh-sshell
Start-SshAgent

It should automagically pick up any key-files in your ~/.ssh.

Solution 3:[3]

If you are using Windows' native implementation of OpenSSH with the native ssh-agent Windows service, make sure that git for Windows was configured to use that SSH implementation when you installed it:

Screenshot of Git for Windows installer; choosing the SSH executable. The "Use external OpenSSH" option is selected.

If you used the bundled OpenSSH installation, git will default to that and will not use any keys imported into Windows' native ssh-agent service. You need to select "Use external OpenSSH" instead when prompted.

If you did not make this selection when installing, you should be able to fix that by just running the installer again.

Solution 4:[4]

The issue is the git was unable to find the ssh_agent.exe which supplied the credentials The steps I followed are given below

  1. Searched the ssh_agent.exe file drive
  2. Added the path as environment path int the profile.example.ps1 file

$env:path += ";" + "C:\Program Files\Git\usr\bin"

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Garry Polley
Solution 2 Jonatan Lindén
Solution 3 Ajedi32
Solution 4 Naveen Muralidharan