简体   繁体   English

如何将 VSCode 配置为自动获取 git 而无需在 Windows 上询问 SSH 密钥密码 10

[英]How to configure VSCode to auto git fetch without asking for SSH key password on Windows 10

Because of this password prompt, auto-fetch, push and pull from VSCode doesn't work.由于此密码提示,从 VSCode 自动获取、推送和拉取不起作用。 This requires me to manually push/pull from the integrated terminal (which will prompt me a password).这需要我从集成终端手动推/拉(这将提示我输入密码)。

However, when I run ssh -T git@github.com-work within the Integrated Terminal of VSCode, I am able to ssh in without a password prompt (which is what I am trying to achieve).但是,当我在 VSCode 的集成终端中运行ssh -T git@github.com-work时,我能够在没有密码提示的情况下输入 ssh(这是我想要实现的)。 I have already added the ssh keys via ssh-add and I see them using ssh-add -L .我已经通过ssh-add添加了 ssh 密钥,我使用ssh-add -L看到了它们。 Similarly, I am able to run ssh -T git@github.com-work in Windows Terminal without being prompted for the password.同样,我可以在 Windows 终端中运行ssh -T git@github.com-work而无需提示输入密码。

What I wish to achieve is being able to push and pull my repositories using VSCode's inbuilt tools without the password prompt every time I attempt to fetch, pull or push.我希望实现的是能够使用 VSCode 的内置工具推送和拉取我的存储库,而无需每次我尝试获取、拉取或推送时提示密码 This password prompt is preventing VSCode from auto-fetching or updating my repository by clicking the sync icon on the bottom right ( results in a Permission denied(publickey, keyboard-interactive) prompt from VSCode )此密码提示阻止 VSCode 通过单击右下角的同步图标自动获取或更新我的存储库(导致 VSCode 出现 Permission denied(publickey, keyboard-interactive) 提示

Edit :编辑

Thanks to VonC, I don't have to type my password everytime I run git fetch etc. within VSCode's integrated terminal.感谢 VonC,我不必每次在 VSCode 的集成终端中运行git fetch等时都输入密码。 This was solved by adding这是通过添加解决的

$env:GIT_SSH="C:\Windows\System32\OpenSSH\ssh.exe"

to my Powershell profile.到我的 Powershell 个人资料。

However, it still didn't resolve the main issue that VSCode's internal source control tools are unable to pull from git@github.com-work but keeps trying at git@github.com .但是,它仍然没有解决 VSCode 内部源代码控制工具无法从git@github.com-work拉取但一直在git@github.com拉取的主要问题。

Make sure the remote origin URL used by VSCode is actually github.com-work (check that in the VSCode output terminal for 'Git').确保 VSCode 使用的远程原点 URL 实际上是github.com-work (在 VSCode output 终端中检查)。
You don't even need git if your %USERPROFILE%\.ssh\config file does specify User git under the entry Host github.com-work )如果您的%USERPROFILE%\.ssh\config文件确实在条目Host github.com-work下指定了User git ,那么您甚至不需要 git

And as mentioned here , launch VSCode (for testing) from a CMD where you have:并且如此处所述,从您拥有的 CMD 启动 VSCode(用于测试):

set GIT_SSH=C:\Windows\System32\OpenSSH\ssh.exe

These extra steps did the trick: ref这些额外的步骤起到了作用:参考

The key is to use Windows' OpenSSH as mentioned, but also need to setup git config file to load the key in the Windows Agent.关键是如上所述使用Windows的OpenSSH,但还需要设置git配置文件以将密钥加载到Windows代理中。

    AddKeysToAgent yes
    IdentitiesOnly yes

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM