作为断电的一部分,密码身份验证被暂时禁用。请改用个人访问令牌

Shr*_*hav 237 git github token git-pull github-api

我使用用户名密码来推送我的代码,它已经工作了几个月,但突然间我无法做到并收到此错误:

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.
Run Code Online (Sandbox Code Playgroud)

请注意,该链接没有帮助。即使使用生成的令牌也无济于事。

主持人注意:这是GitHub 计划中且即将进行的永久性服务更改的一部分

Kus*_*tha 162

  1. 从 github 的开发设置生成新令牌
  2. 更新远程 URL git remote set-url origin https://<token>@github.com/<git_url>
  3. 拉一次: git pull https://<token>@<git_url>.git

你很高兴去。

  • IMO 这不是一个好的解决方案。这里的问题是 PAT 以纯文本形式存储在远程 URL 本身中。因此,如果有人能够访问远程 URL,那么他们就可以访问您的 PAT 以执行任何操作。令牌应该安全地存储在钥匙串或类似的东西中。编辑:我特别指的是第 3 步,在该步骤中您将 PAT 作为前缀添加到远程 URL。 (27认同)
  • 什么是 &lt;git_url&gt; ? (13认同)
  • 嘿伙计们,您可以设置远程网址,而不是删除并添加它。请按照说明使用```git remote set-url &lt;remote name&gt; https://&lt;token&gt;@github.com/&lt;git_url&gt;``` (8认同)
  • 没有“git dev 设置”。我希望得到一个带有金色徽章的答案来了解 git 和 GitHub 之间的区别。 (5认同)

Nag*_*ram 137

编辑

以前接受的答案 /sf/answers/4773476991/ 可以 完成这项工作,但它不安全,因为我们以纯文本形式存储令牌。

在我的诚实看来,将它存储在钥匙串中是更好的方法。

对于 Visual Studio Code,请阅读此答案:https : //stackoverflow.com/a/68192584/7942242

对于 Windows:

你可以试试下面的@Venryx 评论,但我还没有测试过。


对于 Mac:

我现在才遇到这个问题

在此处输入图片说明

按照建议,我按照这个 url进入了开发设置并生成了一个令牌

然后我在我的 Mac 中访问了我的钥匙链

在此处输入图片说明

我删除了(所有)GitHub 的行

在此处输入图片说明

现在我去了终端并推送了一个虚拟代码

git push
Run Code Online (Sandbox Code Playgroud)

终端要求我输入帐户的电子邮件和密码。

我输入了我的电子邮件,对于密码,我输入了我之前生成的令牌。

在此处输入图片说明

它又开始工作了。

  • 在 Windows 上,使用“凭据管理器”而不是“钥匙串访问”。另外,请确保使用“Powershell”而不是命令提示符,否则会出错。有关完整说明,请参见此处:/sf/answers/4773467611/ (3认同)
  • 您不需要删除钥匙串,您只需编辑密码并添加令牌即可 (2认同)

Sif*_*que 45

macOS 解决方案

我只是按照以下说明进行操作,这解决了我的问题。

  1. 为 github 生成个人访问令牌。生成令牌的过程
  2. 打开你的Keychain Access.
  3. 搜索github.com并双击它。
  4. password使用key您最近生成的更新。

注意:我不确定这是否适用于其他操作系统用户。


dPa*_*Pac 28

这是一个简单的解决方案:

  • 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
Run Code Online (Sandbox Code Playgroud)
  • 要更改默认密码缓存超时,请输入以下内容:
# Set the cache to timeout after 1 hour (setting is in seconds)
$ git config --global credential.helper 'cache --timeout=3600'
Run Code Online (Sandbox Code Playgroud)

  • 这是最好的答案……但又多了一个步骤。在此之前我必须设置“git config --unset credential.helper”...然后我输入“git config --global credential.helper cache”,然后我就很好了。我最后一次必须输入我的用户名/新密钥......然后我很好。 (2认同)

Avn*_*wal 20

密码验证已被 GitHub 禁用,不再受支持。创建并使用个人访问令牌而不是密码。

要遵循的步骤:

  1. 从钥匙串中删除 GitHub 存储的凭据。(例如,在 Mac 上使用“Keychain Access”,或在 Windows 上使用“Credential Manager”)
  2. 从 Github Settings->Developer Settings->Personal access tokens->Generate new token 生成访问令牌
  3. 保存令牌 - 因为它只能在那里使用一次
  4. 运行命令git fetch(或者git push,如果获取不需要权限)

    如果在 Windows 上,您必须从 Powershell 运行它,而不是命令提示符。remote: Password authentication is temporarily disabled尽管输入相同,但命令提示符始终失败并显示消息。

  5. 它会询问您的用户名和密码。

    如果它没有询问您的用户名和密码,您必须更改您的 git remote url 以包含您的用户名:(https://USERNAME@github.com/repo-owner/repo-name.git有关更改远程 url 的说明,请参阅方法 2)

  6. 当它要求输入密码时,输入访问令牌而不是密码。(您必须输入两次)

或第二种方法:

  1. 从 Github Settings->Developer Settings->Personal access tokens->Generate new token 生成访问令牌
  2. 在本地更新来源的 URL: git remote set-url origin https://<token>@<git_url>.git
  3. 拉一次: git pull https://<token>@<git_url>.git

  • 或者更好的是,一个 SSH 密钥 (4认同)

crg*_*g63 18

适用于 MacOS、Windows 和 Linux

解决方案1

  1. 删除现有的存储库(如果您有任何当前更改,请备份它)mv my-repo my-repo.backup

  2. 创建一个 SSH 密钥并将其添加到 GitHub(请参阅GitHub 文档

  3. 克隆 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?)

  1. git远程删除原点

  2. 您必须添加访问令牌(请参阅GitHub 文档以生成令牌)

  3. git remote add origin https://<token>@<git_url>.git

  4. git pull https://<token>@<git_url>.git

使用VScode

  1. 删除您的 GitHub 访问权限:
git credential-osxkeychain erase 
?  host=github.com  
?  protocol=https
Run Code Online (Sandbox Code Playgroud)
  1. git push或者git pull 它会提示您模态单击“允许”并按照该过程进行操作。

  • 使用新的个人令牌删除并读取原点对我有用。/sf/answers/4773476991/ (2认同)

小智 14

如果您使用的是 MacOS

  1. 首先请删除钥匙串中的所有 github 凭据,然后由于 github 安全策略 Github --> 设置 --> 开发人员设置 --> 个人访问令牌,请生成您的令牌以用作密码

  2. 尝试在你的 repo 上推送或拉取最新的东西,然后 git 会询问你的用户名和密码,输入你的用户名和你从 github 生成的令牌

  • 或者,在钥匙串 Access.app 中搜索“github”并找到类型列为“Internet 密码”的条目(您可能有“Web 表单密码”条目,这些条目不是终端正在使用的条目)。双击该条目进行编辑。选中“显示密码”框。将密码替换为 github 令牌。单击“保存更改”。您现在应该能够像以前一样做所有事情。希望这有帮助。 (2认同)

E J*_*rod 10

如果您使用 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
Run Code Online (Sandbox Code Playgroud)
  • 如果您克隆您的存储库
git clone https://<USERNAME>:<TOKEN>@<GIT_URL>.git
Run Code Online (Sandbox Code Playgroud)


Sai*_*jee 10

尝试了所有方法,最后,它对我有用,由于此错误,我无法推送我的 repo,所以请至少尝试一次!

_____________________________生成个人访问令牌:

  1. 单击此处生成个人访问令牌,这很容易

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

Run Code Online (Sandbox Code Playgroud)

我受了很多苦,希望能帮到你!

  • 这个解决方案效果最好,因为我在 Linux 服务器上,而 Windows 和 Mac 钥匙串不可用。 (2认同)
  • 这在 Windows 10 上对我有用。感谢你把它留在这里。简单的。GitHub 应该在文档中包含这样的内容。 (2认同)

小智 7

  1. 创建个人访问令牌(https://docs.github.com/en/github/authenticating-to-github/keeping-your-account-and-data-secure/creating-a-personal-access-token

  2. 在你的 vs 代码命令行上..

    git config --global credential.helper [YOUR_TOKEN]

  • 注意:如果您已经将 git 设置为从系统凭据管理器中读取,而不是在 git 配置中进行硬编码,那么这将不起作用。不幸的是,git 不会警告你这一点,所以只是默默地失败了,因为它使用过时的凭据管理器条目而不是上面命令添加的新访问令牌。要将访问令牌添加到您的系统凭据管理器,请参见此处:/sf/answers/4773467611/ (2认同)

Tie*_*yen 5

Ubuntu Server 现有git的解决方案

删除密码:

git config --global --unset user.password;
git config --local --unset user.password;
Run Code Online (Sandbox Code Playgroud)

更改 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"
Run Code Online (Sandbox Code Playgroud)

拉/推

git pull
git push origin HEAD:develop
Run Code Online (Sandbox Code Playgroud)

输入从这里生成的个人访问令牌:

https://github.com/settings/tokens