Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git in Powershell saying 'Could not find ssh-agent'

Tags:

git

ssh

I have git installed and it works great in the command prompt, but when I open up powershell it gives me this warning:

WARNING: Could not find ssh-agent 

I have pageant running and loaded with my private key. This works in all the gui tools and the command prompt but not in Powershell.

What's going on?

like image 980
Khalid Abuhakmeh Avatar asked Sep 19 '11 11:09

Khalid Abuhakmeh


People also ask

Could not open a connection to your authentication agent ssh-add Windows 10?

On the other hand, if you get the “Could not open a connection to your authentication agent” error again, the agent needs full reassignment. If you're working with the regular shell, then just run ssh-agent /bin/sh and then ssh-add ~/. ssh/id_rsa, once again making sure to replace the name of the key.


1 Answers

For those looking for a detailed explanation have a read of this blog post. Below is a quote from the blog post. Ultimately the ssh-agent.exe needs to be in the path, or resolved some other way.

EDIT: It appears most of the people don't bother reading the linked blog and the original extract did not quote the full solution, so I've expanded the quote from the blog below.

There are numerous ways to resolve the error, based on the likes to all other answers. One known to work is quoted below. Scan though other answers they may be more appropriate for you.

When I restarted my PowerShell prompt, it told me it could not start SSH Agent.

It turns out that it was not able to find the “ssh-agent.exe” executable. That file is located in C:\Program Files (x86)\Git\bin. but that folder isn’t automatically added to your PATH by msysgit.

If you don’t want to add this path to your system PATH, you can update your PowerShell profile script so it only applies to your PowerShell session. Here’s the change I made.

$env:path += ";" + (Get-Item "Env:ProgramFiles(x86)").Value + "\Git\bin"

On my machine that script is at: C:\Users\Haacked\Documents\WindowsPowerShell\Microsoft.Powershell_profile.ps1

like image 72
Taras Alenin Avatar answered Sep 24 '22 08:09

Taras Alenin