作为断电的一部分,密码身份验证被暂时禁用。请改用个人访问令牌
我使用用户名密码来推送我的代码,它已经工作了几个月,但突然间我无法做到并收到此错误:
Username for 'https://github.com': shreyas-jadhav
Password for 'https://shreyas-jadhav@github.com':
remote: Password authentication is temporarily disabled as part of a brownout. Please use a personal access token instead.
remote: Please see https://github.blog/2020-07-30-token-authentication-requirements-for-api-and-git-operations/ for more information.
请注意,该链接没有帮助。即使使用生成的令牌也无济于事。
主持人注意:这是GitHub 计划中且即将进行的永久性服务更改的一部分
回答
- 从 github 的开发设置生成新令牌
- 更新远程 URL
git remote set-url origin https://<token>@github.com/<git_url> - 拉一次:
git pull https://<token>@<git_url>.git
你很高兴去。
- IMO 这不是一个好的解决方案。这里的问题是 PAT 以纯文本形式存储在远程 URL 本身中。因此,如果有人能够访问远程 URL,那么他们就可以访问您的 PAT 以执行任何操作。令牌应该安全地存储在钥匙串或类似的东西中。编辑:我特别指的是第 3 步,在该步骤中您将 PAT 作为前缀添加到远程 URL。
- what is <git_url> ?
- 嘿伙计们,您可以设置远程网址,而不是删除并添加它。请按照说明使用```git remote set-url <remote name> https://<token>@github.com/<git_url>```
- 没有“git dev 设置”。我希望得到一个带有金色徽章的答案来了解 git 和 GitHub 之间的区别。
回答
编辑
以前接受的答案
/sf/answers/4773476991/ 可以
完成这项工作,但它不安全,因为我们以纯文本形式存储令牌。
在我的诚实看来,将它存储在钥匙串中是更好的方法。
对于 Visual Studio Code,请阅读此答案:https :
//stackoverflow.com/a/68192584/7942242
对于 Windows:
你可以试试下面的@Venryx 评论,但我还没有测试过。
对于 Mac:
我现在才遇到这个问题
按照建议,我按照这个 url进入了开发设置并生成了一个令牌
然后我在我的 Mac 中访问了我的钥匙链
我删除了(所有)GitHub 的行
现在我去了终端并推送了一个虚拟代码
git push
终端要求我输入帐户的电子邮件和密码。
我输入了我的电子邮件,对于密码,我输入了我之前生成的令牌。
它又开始工作了。
- 在 Windows 上,使用“凭据管理器”而不是“钥匙串访问”。另外,请确保使用“Powershell”而不是命令提示符,否则会出错。有关完整说明,请参见此处:/sf/answers/4773467611/
- 您不需要删除钥匙串,您只需编辑密码并添加令牌即可
回答
macOS 解决方案
我只是按照以下说明进行操作,这解决了我的问题。
- 为 github 生成个人访问令牌。生成令牌的过程
- 打开你的
Keychain Access. - 搜索
github.com并双击它。 password使用key您最近生成的更新。
注意:我不确定这是否适用于其他操作系统用户。
回答
这是一个简单的解决方案:
- 去
Github->Settings->Developer settings->Personal access tokens。重新生成您的令牌并复制它。 - 在您的任何本地存储库上,when
git push,输入您的用户名,密码是生成的令牌
您可以使用 Git 客户端缓存您的令牌,而不是为每个 HTTPS Git 操作手动输入您的令牌。
- 在终端中,输入以下内容:
# Set git to use the credential memory cache
$ git config --global credential.helper cache
- 要更改默认密码缓存超时,请输入以下内容:
# Set the cache to timeout after 1 hour (setting is in seconds)
$ git config --global credential.helper 'cache --timeout=3600'
- 这是最好的答案……但又多了一个步骤。在此之前我必须设置“git config --unset credential.helper”...然后我输入“git config --global credential.helper cache”,然后我就很好了。我最后一次必须输入我的用户名/新密钥......然后我很好。
回答
密码验证已被 GitHub 禁用,不再受支持。创建并使用个人访问令牌而不是密码。
要遵循的步骤:
- 从钥匙串中删除 GitHub 存储的凭据。(例如,在 Mac 上使用“Keychain Access”,或在 Windows 上使用“Credential Manager”)
- 从 Github Settings->Developer Settings->Personal access tokens->Generate new token 生成访问令牌
- 保存令牌 - 因为它只能在那里使用一次
- 运行命令
git fetch(或者git push,如果获取不需要权限)
如果在 Windows 上,您必须从 Powershell 运行它,而不是命令提示符。
remote: Password authentication is temporarily disabled尽管输入相同,但命令提示符始终失败并显示消息。 - 它会询问您的用户名和密码。
如果它没有询问您的用户名和密码,您必须更改您的 git remote url 以包含您的用户名:(
https://USERNAME@github.com/repo-owner/repo-name.git有关更改远程 url 的说明,请参阅方法 2) - 当它要求输入密码时,输入访问令牌而不是密码。(您必须输入两次)
或第二种方法:
- 从 Github Settings->Developer Settings->Personal access tokens->Generate new token 生成访问令牌
- 在本地更新来源的 URL:
git remote set-url origin https://<token>@<git_url>.git - 拉一次:
git pull https://<token>@<git_url>.git
- 或者更好的是,一个 SSH 密钥
回答
适用于 MacOS、Windows 和 Linux
解决方案1
-
删除现有的存储库(如果您有任何当前更改,请备份它)
mv my-repo my-repo.backup -
创建一个 SSH 密钥并将其添加到 GitHub(请参阅GitHub 文档)
-
克隆 SSH 的 repo
git clone git@github.com:group/repo-name.git
解决方案 2 (?R?e?c?o?m?m?e?n?d?e?d??s?o?l?u?t?i?o?n?)
-
git远程删除原点
-
您必须添加访问令牌(请参阅GitHub 文档以生成令牌)
-
git remote add origin https://<token>@<git_url>.git -
git pull https://<token>@<git_url>.git
使用VScode
- 删除您的 GitHub 访问权限:
git credential-osxkeychain erase
? host=github.com
? protocol=https
git push或者git pull
它会提示您模态单击“允许”并按照该过程进行操作。
回答
如果您使用的是 MacOS
-
首先请删除钥匙串中的所有 github 凭据,然后由于 github 安全策略 Github --> 设置 --> 开发人员设置 --> 个人访问令牌,请生成您的令牌以用作密码
-
尝试在你的 repo 上推送或拉取最新的东西,然后 git 会询问你的用户名和密码,输入你的用户名和你从 github 生成的令牌
- Alternatively, in keychain Access.app search for "github" and find the entry with the Kind listed as "Internet Password" (you may have entries for "Web form password" these are not what the terminal is using). Double click the entry to edit it. Check the box to "Show password". Replace the password with a github token. Click "Save Changes". You should now be able to do everything as before. Hope that's helpful.
回答
如果您使用 https
-
如文档中所示,在您的令牌设置中生成一个令牌
-
如果存储库已存在,则必须以以下格式更改远程 URL:
https://<username>:<token>@github.com/<repository_url>
git remote remove origin
git remote add origin https://<USERNAME>:<TOKEN>@<GIT_URL>.git
git pull # verify
- 如果您克隆您的存储库
git clone https://<USERNAME>:<TOKEN>@<GIT_URL>.git
回答
尝试了所有方法,最后,它对我有用,由于此错误,我无法推送我的 repo,所以请至少尝试一次!
_____________________________生成个人访问令牌:
- 单击此处生成个人访问令牌,这很容易
https://docs.github.com/en/github/authenticating-to-github/keeping-your-account-and-data-secure/creating-a-personal-access-token
现在只需使用 PAT 而不是密码和用户名的帮助来推送它__________________
2 将更改推送到您的存储库:
git push https://[Personal Access Token]@github.com/[User Name]/[Repository Name].git
我受了很多苦,希望能帮到你!
- 这在 Windows 10 上对我有用。感谢你把它留在这里。简单的。GitHub 应该在文档中包含这样的内容。
回答
-
创建个人访问令牌(https://docs.github.com/en/github/authenticating-to-github/keeping-your-account-and-data-secure/creating-a-personal-access-token)
-
在你的 vs 代码命令行上..
git config --global credential.helper [YOUR_TOKEN]
- 注意:如果您已经将 git 设置为从系统凭据管理器中读取,而不是在 git 配置中进行硬编码,那么这将不起作用。不幸的是,git 不会警告你这一点,所以只是默默地失败了,因为它使用过时的凭据管理器条目而不是上面命令添加的新访问令牌。要将访问令牌添加到您的系统凭据管理器,请参见此处:/sf/answers/4773467611/
回答
Ubuntu Server 现有git的解决方案
删除密码:
git config --global --unset user.password;
git config --local --unset user.password;
更改 remote.origin.url 替换为您的 github 用户名:
git config --global --replace-all remote.origin.url "https://<username>@github.com/PPEProjects/smile-eyes-be.git";
git config --local --replace-all remote.origin.url "https://<username>@github.com/PPEProjects/smile-eyes-be.git"
拉/推
git pull
git push origin HEAD:develop
输入从这里生成的个人访问令牌:
https://github.com/settings/tokens