简体   繁体   English

Visual Studio-Git克隆无法通过SSH进行故障转移,但可以通过HTTPS进行工作

[英]Visual Studio - Git clone fails over SSH, but works over HTTPS

I am using a fresh install of Visual Studio 2017 (15.8.1), and Git tools. 我正在使用Visual Studio 2017(15.8.1)和Git工具的全新安装。 When I try to clone an existing GitHub repository, either by using the commandline tools, or by using git tools, I receive the following error message: 当我尝试使用命令行工具或git工具克隆现有的GitHub存储库时,收到以下错误消息:

git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

I believe this error is caused by SSH and I cannot seem to make git use HTTPS. 我相信此错误是由SSH引起的,我似乎无法使git使用HTTPS。 Thanks in advance. 提前致谢。

If you are using 2-factor authentication at GitHub 如果您在GitHub上使用2要素身份验证

You must either do one of the following: 您必须执行以下任一操作:

  1. Use the SSH link, add an SSH key to your GitHub account and load it using the SSH agent in Windows, this may be done using Putty. 使用SSH链接,将SSH密钥添加到您的GitHub帐户,然后在Windows中使用SSH代理加载它,这可以使用Putty完成。
  2. Generate a personal access token , and use the HTTPS link. 生成个人访问令牌 ,然后使用HTTPS链接。 Use your GitHub username as the username, but use the generated access token as your password. 使用您的GitHub用户名作为用户名,但使用生成的访问令牌作为您的密码。

If you want to clone any repository using https 如果要使用https克隆任何存储库

Simply clone it using the HTTPS-link instead of the SSH link. 只需使用HTTPS链接而不是SSH链接克隆它。 You can find both links here, by clicking on Use SSH , you can switch to the SSH link: 您可以在此处找到两个链接,通过单击Use SSH ,您可以切换到SSH链接:

SSH链接

就我而言,我必须删除〜/ .ssh / known_hosts文件,以便下次您通过ssh访问git时可以创建一个新文件。

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

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