VS Code/Bitbucket/SSH - 权限被拒绝(公钥) [英] VS Code / Bitbucket / SSH - Permission denied (publickey)

查看:163
本文介绍了VS Code/Bitbucket/SSH - 权限被拒绝(公钥)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过 ssh 从 vscode 访问 bitbucket,但总是得到 permission denied (publickey).

I'm trying to access bitbucket via ssh from vscode but always get permission denied (publickey).

SSH 密钥位于 ~.ssh 下,公钥在 bitbucket/settings/security/sshkeys 中正确设置.密钥已经过测试并且可以正常工作!

SSH key(s) are located under ~.ssh, public key(s) are correctly setup in bitbucket/settings/security/sshkeys. The keys are tested and do work!

启动后,我可以从 windows 命令提示符和 powershell 毫无问题地访问我的存储库,但不能从 git bash 或 vscode 访问.在 git bash 中手动设置 ssh 并启动 vscode 可以:

After booting, I can access my repository without problems from the windows command prompt and powershell but NOT from git bash or from vscode. Manually setting up ssh in git bash and starting vscode works though:

eval $(ssh-agent)
ssh-add /c/Users/username/.ssh/privatekey
code

我的环境:

  • Windows 10 企业版 (1803/17134.765)
  • Visual Studio 代码 (1.35.0)
  • git for windows (2.20.1.windows.1)
  • 通过 ssh 获取比特桶
  • 我认为我正在使用在后来的 Windows10 更新之一中引入的 ssh-agent(不知道如何检查,虽然 windows ssh-agent 服务正在运行).李>
  • 我的用户文件夹(包含/.ssh)和 repo 的工作副本位于网络驱动器上
  • Windows 10 Enterprise (1803/17134.765)
  • Visual Studio Code (1.35.0)
  • git for windows (2.20.1.windows.1)
  • bitbucket via ssh
  • I think I'm using the ssh-agent that was introduced in one of the later Windows10 updates (not sure how to check, the windows ssh-agent service is running though).
  • my user folder (containing /.ssh) and the working copy of the repo are located on network drives

对我来说,问题归结为一个问题:为什么 vscode 不使用 windows native,正确设置 ssh 服务,而是依赖 git bash ssh 代理?

免责声明:我花了几个小时阅读有关此主题的主题并摆弄设置.我怀疑这个问题与 Windows10 下网络驱动器的延迟部署有关(一个已知问题).我的 Windows 组策略设置为在启动/登录时等待网络.

Disclaimer: I spent hours reading threads about this topic and fiddling with settings. I suspect the problem to be related to the delayed deployment of network drives under Windows10 (a known issue). My windows group policy is set to wait for the network on boot/login.

推荐答案

Windows 10 允许使用所有默认的 OpenSSH 工具.但是,每次我尝试通过 SSH 从 Github、Gitlab 或 Bitbucket 克隆存储库时,git 都会抛出权限被拒绝.您需要进行一些调整才能使其正常工作.

Windows 10 allows using all default OpenSSH tools. However, git was throwing permission denied for every time when I tried to clone repositories from Github, Gitlab or Bitbucket over SSH. You need to perform a few tweaks to make it work.

  1. 确保 ssh-agent 服务已启用,或在 Powershell 中运行(以管理员身份):

Get-Service -Name ssh-agent |Set-Service -StartupType 手动

  1. ssh-agent
  2. ssh-add
  3. git config --global core.sshCommand C:/Windows/System32/OpenSSH/ssh.exe

这篇关于VS Code/Bitbucket/SSH - 权限被拒绝(公钥)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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