Git在Powershell中说'找不到ssh-agent' [英] Git in Powershell saying 'Could not find ssh-agent'

查看:543
本文介绍了Git在Powershell中说'找不到ssh-agent'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我安装了git,它在命令提示符下工作良好,但是当我打开powershell时,它给了我这个警告:

 警告:无法找到ssh-agent 

我有选美运行并加载了我的私钥。这适用于所有gui工具和命令提示符,但不适用于Powershell。



发生了什么事?

解决方案

对于那些寻找详细解释的人来说,阅读此博文。以下是博客文章的引用。最终, ssh-agent.exe 需要位于路径中,或者以其他方式解决。

编辑:
看起来大多数人不会去阅读链接的博客,原始摘录没有引用完整的解决方案,所以我已经扩展了下面博客的引用。


解决错误的方法有很多,根据喜欢的其他答案。下面引用一个已知的工作。


当我重新启动PowerShell提示时,它告诉我它无法启动SSH代理。

事实证明,它无法找到ssh-agent.exe可执行文件。该文件位于C:\程序文件(x86)\Git\bin。但该文件夹不会通过msysgit自动添加到PATH中。



如果您不想将此路径添加到系统PATH,则可以更新PowerShell配置文件脚本,所以它只适用于你的PowerShell会话。以下是我所做的更改。



$ env:path + =; +(Get-ItemEnv:ProgramFiles(x86))。Value +\Git\bin

在脚本所在的机器上:
C:\ Users \Haacked\Documents\WindowsPowerShell\Microsoft.Powershell_profile.ps1



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?

解决方案

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

这篇关于Git在Powershell中说'找不到ssh-agent'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆