GitHub,HTTPS和Mac应用程序 [英] GitHub, HTTPS and Mac application
问题描述
我知道GitHub中的SSH没有问题(没有用户名/密码来输入每次ie),但我需要使用HTTPS作为我的回购。
现在,我 git init
编辑回购,我承诺,我做了一个 git remote add origin https://github.com/user/repo.git
由GitHub建议。
我准备做一个 git push -u
远程:匿名访问用户/ repo.git被拒绝。
致命:'https://github.com/user/repo.git/'
认证失败
我300%确定我输入了正确的密码(无论如何,我再次尝试了几次)。
我在这里和那里搜索了一下,然后我尝试了我的最后一次机会:为Mac安装GitHub应用程序。
我输入了我的凭据,输入了他们发给我的双因素认证代码,并试图再次推送:这一次运行。
为什么? GitHub应用程序在幕后做了什么?这与双因素验证有关吗?
无论如何,我将无法在我设置的每台机器上下载应用程序,也许可以通过自动化此过程一些脚本。
如果您激活了双因素身份验证,您的GitHub密码将不起作用。 b
$ b
您需要生成个人访问令牌,正如我在配置Git客户端,如GitHub对于Windows,不要求认证。
这个长(40个字符)的密码将作为您的GitHub密码而不是
PAT(Personnal Access令牌)与您的Github密码帐户之间的区别:
- 它不需要第二步,但是:
- 它比简单的密码更复杂(不应该被记住)
- 您可以根据需要生成多少个(例如,您访问GitHub的每台不同计算机都有一个)
- 您可以随时撤销它(比更改GitHub密码容易) $ b $您可以在
.netrc.gpg
文件中加密您的GitHub凭证,正如我在 a href =https://stackoverflow.com/a/18362082/6309>有没有办法在使用https:// github时跳过密码输入。
我发现远远优于内存缓存机制(如credential-osxkeychain),因为您不必在每个会话中输入GitHub(长和复杂的令牌)密码。
只需键入您的密码gpg密钥,用于该GitHub登录/令牌凭证或用于您在
〜/ .netrc.gpg
文件中加密的任何其他凭证。 I know SSH in GitHub causes no problem (no username/password to type everytime i.e.), but I need to use HTTPS for a repo of mine.
Now, I git init
ed the repo, I committed, I did a git remote add origin https://github.com/user/repo.git
as suggested by GitHub.
I was about to do a git push -u origin master
: first it promped me for username and password, and then answered with:
remote: Anonymous access to user/repo.git denied.
fatal: Authentication failed for 'https://github.com/user/repo.git/'
I'm 300% sure I typed the right password (and I tried again a couple times anyway). I googled here and there, and then I tried my last chance: installing the GitHub app for Mac. I entered my credentials, entered the 2-factor auth code they sent me, and tried to push again: this time it worked.
Why? What did the GitHub app do behind the scenes? Has it something to do with the 2-factor auth?
Anyway, I would be able to not download the app on every machine I setup, maybe by automating this process with some script.
Your GitHub password won't work if you have activated the two-factor authentication.
You need to generate a Personal Access Token, as I explain in "Configure Git clients, like GitHub for Windows, to not ask for authentication".
That long (40 characters) password will work as your GitHub password without requiring a second authentication.
The difference between a PAT (Personnal Access token) and your Github password account:
- It doesn't required the second step, but:
- it is more complex than a simple password (not meant to be remembered)
- you can generate as many as you want (one for each different computer from which you access GitHub, for instance)
- you can revoke it at any time (easier than having to change your GitHub password)
And you can encrypt your GitHub credential in a .netrc.gpg
file, as I illustrate in "Is there a way to skip password typing when using https:// github".
I find that far superior to a memory-caching mechanism (like credential-osxkeychain), since you don't have to type your GitHub (long and complex token) password at each session.
You only type the passphrase of your gpg key, for that GitHub login/token credential, or for any other credential that you have encrypted in your ~/.netrc.gpg
file.
这篇关于GitHub,HTTPS和Mac应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!