【问题标题】:Git: Clone in VS Code returns "Permission denied, please try again" - git clone in terminal worksGit:VS Code 中的克隆返回“权限被拒绝,请重试” - 终端中的 git clone 有效
【发布时间】:2019-03-16 17:40:23
【问题描述】:

Git: Clone 在 Mac 上的 Visual Studio Code 中返回 Permission denied, please try again。从 Visual Studio Code 中的终端,它可以执行git clone

在 Mac 上的 Visual Studio Code 中,我执行以下操作:

  1. 我愿意Git: Clone
  2. 我输入了以下格式的 ssh 存储库 URL:ssh://<username>@<repository-host>/<path>/<rep>.git

  3. 我“选择存储库位置”文件夹,并得到以下对话框:

此功能从不要求我输入任何密码!

如果我打开 Git 日志,输出是这样的:

> git clone <ssh-repository-URL> <path>
Cloning into '<path>'...
Permission denied, please try again.
Permission denied, please try again.
Received disconnect from <IP> port 22:2: Too many authentication failures for <username>
Disconnected from <IP> port 22
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

在终端中它可以工作:

mac:rep username$ git clone 
Cloning into '<repository>'… <ssh-repository-URL>
The authenticity of host ‘<repository-host> (<repository-ip>)' can't be established.
ECDSA key fingerprint is SHA256:<fingerprint>.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '<repository-host>,<repository-ip>' (ECDSA) to the list of known hosts.
Password:
remote: ...
remote: ...
remote: …
Receiving objects: 100% (.../...), ... | ... MiB/s, done.
Resolving deltas: 100% (.../...), done.

关于为什么Git: Clone Visual Studio Code 从不询问服务器密码的任何线索?

【问题讨论】:

  • 从你上面提到的,我认为VS Code拒绝远程是因为终端部分提到的真实性问题。您可以尝试使用https 而不是ssh 克隆回购吗?
  • @dstrants 谢谢。我将更新这个问题,因为 Git: Clone 永远不会询问存储库服务器的密码。在终端中,我可以输入密码。关于https,我认为我们的本地存储服务器不支持。
  • 您是否为您的 ssh 密钥添加了密码?
  • @evolutionxbox 非常感谢!这个问题实际上使我找到了解决问题的方法,因为我不知道您只能在 Git 中使用 ssh URL:正确设置 ssh 密钥时克隆。
  • 您可以添加您的解决方案作为答案吗?

标签: git macos visual-studio-code


【解决方案1】:

在设置存储库 URL 并选择目标文件夹后,Git: Clone 中的底层功能似乎与用户没有任何交互。

要让 ssh-repository 与 Visual Studio Code 一起工作,您需要执行以下操作:

  1. 打开终端
  2. 运行ssh-keygen生成ssh密钥对
  3. 运行ssh-copy-id -i ~/.ssh/id_rsa &lt;username&gt;@&lt;repository-host&gt;

源自此question 和此answer

关于版本控制的 VS Code 用户指南在常见问题下有以下问题/答案:

Can I use SSH Git authentication with VS Code? 是的,尽管 VS Code 最容易使用没有密码的 SSH 密钥。如果您有带密码的 SSH 密钥,则需要从 Git Bash 提示符启动 VS Code 以继承其 SSH 环境。

【讨论】:

  • 我花了 3 个小时才弄清楚密码短语的使用不是直接在 vs 代码 git 克隆中使用的。
猜你喜欢
  • 1970-01-01
  • 2018-04-15
  • 2011-12-15
  • 1970-01-01
  • 2016-09-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-08-17
相关资源
最近更新 更多