我在 Windows 上运行 OpenSSH,使用自秋季/秋季创作者更新以来包含内置 OpenSSH https://learn.microsoft.com/en-us/windows-server/administration/openssh/openssh_overview.
我在 PowerShell 中使用 ssh 效果很好,但 Visual Studio 远程开发(我猜 Windows 版的 Git?)没有使用我的 OpenSSH。相反,他们似乎使用 MinGW 的适用于 Windows SSH 客户端的 Git。这意味着我所有的ssh-add
ed 键不存在于 VS 或 Git 中ssh-agent
.
我怎样才能让 Visual Studio(也许还有 Git?)使用内置的 OpenSSH 安装,以便我可以使用相同的ssh-agent
他们之间?
电源外壳
以下是 SSH 在 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.
视觉工作室
我在用VS Code 远程开发 https://code.visualstudio.com/docs/remote/remote-overview。每次登录远程计算机时,系统都会提示我输入私钥密码。
如果没有私钥身份验证,系统会提示我输入登录密码(对于远程用户)。
免责声明:我在 Microsoft 工作。