GitHub通过https使用双因素身份验证进行克隆 [英] Git Clone from GitHub over https with two-factor authentication

查看:805
本文介绍了GitHub通过https使用双因素身份验证进行克隆的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近开始在GitHub上使用双因素身份验证,现在我无法以通常方式在私有回购站上通过https使用git:

  peter @ computer:〜$ git clone https://github.com/[...]/MyPrivateRepo 
克隆到'MyPrivateRepo'中...
'https: //github.com':[...]
'https:// [...] @ github.com'的密码:
remote:无效的用户名或密码。
致命:'https://github.com/[...]/MyPrivateRepo/'


$验证失败b $ b

如果我禁用双因素认证,我可以像以前一样使用它:

  peter @ computer:〜$ git clone https://github.com/[...]/MyPrivateRepo 
克隆到'MyPrivateRepo'...
'https://github.com'的用户名:[...]
'https:// [...] @ github.com'的密码:
remote:计数对象:147,完成。
remote:合计147(delta 0),重用0(delta 0),pack-reused 147
接收对象:100%(147/147),22.70 KiB | 0字节/秒,完成。
解决三角洲问题:完成100%(87/87)。
检查连通性...完成。

我知道我可以使用SSH并且一切正常,但是有没有办法保留双因子身份验证,同时仍然可以通过HTTPS使用GitHub,例如通过发送auth令牌和我的请求?

了解如何在这里解决这个问题:



https://github.com/blog/1614-two-factor-authentication#how-does-it-work-for-command-line-git


它对命令行Git有效吗?



如果您正在使用SSH进行Git身份验证,这很简单:您无需执行任何操作。如果您使用HTTPS Git,而不是输入密码,请输入个人访问令牌。这些可以通过访问个人访问令牌页面来创建。


blockquote>

I recently began using two-factor authentication on GitHub, and I am now unable to use git over https on private repos in the usual way:

peter@computer:~$ git clone https://github.com/[...]/MyPrivateRepo
Cloning into 'MyPrivateRepo'...
Username for 'https://github.com': [...]
Password for 'https://[...]@github.com': 
remote: Invalid username or password.
fatal: Authentication failed for 'https://github.com/[...]/MyPrivateRepo/'

If I disable two-factor authentication I can use it as before:

peter@computer:~$ git clone https://github.com/[...]/MyPrivateRepo
Cloning into 'MyPrivateRepo'...
Username for 'https://github.com': [...]
Password for 'https://[...]@github.com': 
remote: Counting objects: 147, done.
remote: Total 147 (delta 0), reused 0 (delta 0), pack-reused 147
Receiving objects: 100% (147/147), 22.70 KiB | 0 bytes/s, done.
Resolving deltas: 100% (87/87), done.
Checking connectivity... done.

I know I can use SSH and everything works, but is there a way I can keep two-factor authentication while still being able to use GitHub over HTTPS, for example by sending an auth token with my request?

解决方案

Find out how to fix this here:

https://github.com/blog/1614-two-factor-authentication#how-does-it-work-for-command-line-git

How does it work for command-line Git?

If you are using SSH for Git authentication, rest easy: you don't need to do anything. If you are using HTTPS Git, instead of entering your password, enter a personal access token. These can be created by going to your personal access tokens page.

这篇关于GitHub通过https使用双因素身份验证进行克隆的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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