本文介绍了如何在VS Code中使用Windows内置的OpenSSH ssh-agent,而不是Git bash?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我正在Windows上使用内置-自秋季/秋季创作者更新以来包含在OpenSSH中.

I am running OpenSSH on Windows, using the built-in OpenSSH included since the Autumn/Fall Creators Update.

我在PowerShell中使用ssh很好,但是Visual Studio远程开发(我猜是Windows的Git吗?)未使用OpenSSH.取而代之的是,他们似乎正在使用MinGW的Git for Windows SSH客户端.这意味着我所有 ssh-add 键都不在VS或Git ssh-agent 中.

I am using ssh just fine in my PowerShell, but Visual Studio Remote Development (and I guess Git for Windows?) are not using my OpenSSH. Instead, they seem to be using the Git for Windows SSH client from MinGW. This means all my ssh-added keys are not present in the VS or Git ssh-agent.

如何获取Visual Studio(也许还有Git?)以使用内置的OpenSSH安装,以便可以在它们之间使用相同的 ssh-agent ?

How can I get Visual Studio (and maybe Git?) to use the builtin OpenSSH install so that I can use the same ssh-agent between them all?

这是SSH在PowerShell中的外观:

Here is what SSH looks like in PowerShell:

c:\Users\myusername
> Get-Command ssh

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Application     ssh.exe                                            7.7.2.1    C:\WINDOWS\System32\OpenSSH\ssh.exe

c:\Users\myusername
> Get-Command ssh-agent

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Application     ssh-agent.exe                                      7.7.2.1    C:\WINDOWS\System32\OpenSSH\ssh-agent.exe

C:\Users\myusername
> Get-Command ssh-add

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Application     ssh-add.exe                                        7.7.2.1    C:\WINDOWS\System32\OpenSSH\ssh-add.exe

c:\Users\myusername
> ssh-add -l
2048 SHA256:HASH_HERE C:\Users\myusername\.ssh\id_rsa (RSA)

Git Bash

myusername@COMPUTERNAME MINGW64 ~
$ which ssh
/usr/bin/ssh

myusername@COMPUTERNAME MINGW64 ~
$ which ssh-agent
/usr/bin/ssh-agent

myusername@COMPUTERNAME MINGW64 ~
$ which ssh-add
/usr/bin/ssh-add

myusername@COMPUTERNAME MINGW64 ~
$ ssh-add -l
Could not open a connection to your authentication agent.

Visual Studio

我正在使用 VS代码远程开发.每次登录到远程计算机时,系统都会提示我输入私钥的密码.

Visual Studio

I am using VS Code Remote Development. Every time I log in to my remote computer, I am prompted for my private key's password.

没有私钥身份验证,系统会提示我输入登录密码(对于远程用户).

Without private key auth, I am prompted for my logon password (for the remote user).

推荐答案

这是 VS Code远程开发的已知问题/回归.

解决方法很简单:更改VS Code的SSH路径.

The workaround is simple: change VS Code's SSH path.

  1. 打开VS Code设置.
  2. 搜索 remote.SSH.path .
  3. 将设置更改为 C:\ Windows \ System32 \ OpenSSH \ ssh.exe (或 C:\\ Windows \\ System32 \\ OpenSSH \\ ssh.exe >如果是编辑JSON).
  1. Open VS Code settings.
  2. Search for remote.SSH.path.
  3. Change the setting to C:\Windows\System32\OpenSSH\ssh.exe (or C:\\Windows\\System32\\OpenSSH\\ssh.exe if editing JSON).

VS Code现在将使用OpenSSH ssh-agent .

VS Code will now use the OpenSSH ssh-agent.

这篇关于如何在VS Code中使用Windows内置的OpenSSH ssh-agent,而不是Git bash?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-07 16:56