【问题标题】:Using VS Code with native Windows OpenSSH client将 VS Code 与本机 Windows OpenSSH 客户端一起使用
【发布时间】:2021-07-17 05:38:27
【问题描述】:

我正在尝试从 Putty/Pagent/plink 传递到 Windows OpenSSH 本机客户端。

我已经设法在TortoiseGit 中做到这一点,但VSCode 的主要问题似乎是我无法设置要使用的 ssh 代理。

我在 Windows 上启用了 OpenSSH 代理服务以自动启动,并将我的开放 ssh 密钥添加到 ssh-add。

每次我尝试从VSCode 推送时,我得到的只是一条错误消息

Git: FATAL ERROR: Disconnected: No support authentication methods available (server sent: public key)

当我尝试从终端推送时,我也得到了

请确保您具有正确的访问权限并且存储库存在。

如前所述,TortoiseGit 完全没有问题,唯一的区别是在 TortoiseGit 中我设置了ssh-agent。

【问题讨论】:

    标签: windows git visual-studio-code openssh ssh-agent


    【解决方案1】:

    您可能需要确认您的系统环境变量 GIT_SSH 指向 Git 中的 ssh:C:\Program Files\Git\usr\bin\ssh.exe

    【讨论】:

      【解决方案2】:

      您可能需要更新您的 Windows OpenSSH。如果您从 PowerShell 窗口运行 ssh -V 并查看 OpenSSH_for_Windows_7.7p1,则可能是这种情况。 Install Win32 OpenSSH Wiki 中提供了升级说明。

      常规

      VS Code 使用 Windows 版本的 OpenSSH。

      • 您在 VS Code 中更改的配置文件位于 /Users/<username>/.ssh/config
      • 密钥的默认位置/名称是/Users/<username>/.ssh/id_rsa。

      示例

      • 本地:安装了 VS Code 和非常棒的 Remote - SSH 扩展的 Windows 10 机器
      • 远程:Ubuntu,我使用 git 进行开发,需要我的私钥可用
      • 由于远程是共享的,我想使用 SSH 代理转发并将我的私钥保存在本地计算机上
      配置文件:
      Host mybox
        HostName actual.ip.or.name.of.mybox.com
        User myusername
        IdentityFile ~/.ssh/id_rsa
        ForwardAgent yes
      
      PowerShell 命令(以管理员身份运行)
      Start-Service ssh-agent
      ssh-add C:\Users\<username>\.ssh\id_rsa       # private key to add
      ssh-add -L                                    # list keys added
      Set-Service ssh-agent -StartupType Automatic  # optional
      

      【讨论】:

        猜你喜欢
        • 2011-12-19
        • 2019-03-20
        • 2012-10-16
        • 2013-06-18
        • 2010-12-24
        • 2021-01-21
        • 1970-01-01
        • 2014-01-14
        • 2013-01-19
        相关资源
        最近更新 更多