pet*_*r-b 100 git authentication github
我最近开始在GitHub上使用双因素身份验证,我现在无法以通常的方式在私有存储库上使用git over https:
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/'
Run Code Online (Sandbox Code Playgroud)
如果我禁用双因素身份验证,我可以像以前一样使用它:
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.
Run Code Online (Sandbox Code Playgroud)
我知道我可以使用SSH,一切正常,但有没有办法可以保持双因素身份验证,同时仍然能够通过HTTPS使用GitHub,例如通过发送带有我请求的身份验证令牌?
Nit*_*sew 112
在这里了解如何解决这个问题:
https://github.com/blog/1614-two-factor-authentication#how-does-it-work-for-command-line-git
它如何用于命令行Git?
如果您使用SSH进行Git身份验证,请轻松休息:您无需执行任何操作.如果您使用的是HTTPS Git,请输入个人访问令牌,而不是输入密码.这些可以通过访问您的个人访问令牌页面来创建.
通常会想到您已经设置了两因素身份验证,经过几次密码尝试和密码重置。那么,我们如何使用双因素身份验证来 git 克隆私有存储库呢?很简单,使用访问令牌。
如何使用访问令牌对 Git 进行身份验证
哇,它有效!
小智 5
第一:获取个人访问令牌。https://github.com/settings/tokens
第二:放置帐户和令牌。例子在这里:
$ git push
Username for 'https://github.com': # Put your GitHub account name
Password for 'https://{USERNAME}@github.com': # Put your Personal access token
Run Code Online (Sandbox Code Playgroud)
有关如何创建个人访问令牌的链接:https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line
归档时间: |
|
查看次数: |
66629 次 |
最近记录: |