我最近开始在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/'
如果禁用两因素身份验证,则可以像以前一样使用它:
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.
我知道我可以使用SSH,并且一切正常,但是有一种方法可以保持两因素身份验证,同时仍然能够通过HTTPS使用GitHub,例如通过在请求中发送身份验证令牌?