【问题标题】:remote: Invalid username or password. fatal: Authentication failed, after two-factor authentication enabled远程:无效的用户名或密码。致命:启用双因素身份验证后身份验证失败
【发布时间】:2017-12-25 15:59:54
【问题描述】:

启用双重身份验证后,我在尝试git clonegit fetch 等时收到以下错误:

remote: Invalid username or password.
fatal: Authentication failed for 'https://github.com/smartsendio/pickup-map.git/'

【问题讨论】:

    标签: git github two-factor-authentication multi-factor-authentication


    【解决方案1】:

    启用双因素认证后,您将无法使用密码访问

    您需要创建个人访问令牌 现在使用访问令牌而不是密码

    【讨论】:

      【解决方案2】:

      获取访问令牌后,您需要运行以下命令之一。然后,当您运行下一个“git push”时,它会询问您的用户名和密码,这是您的访问令牌。

      MAC git config --global credential.helper osxkeychain

      Windows git config --global credential.helper wincred

      【讨论】:

        【解决方案3】:

        一种解决方案是使用个人访问令牌,正如@surendra 已经描述的那样;另一种解决方案是使用受密码保护的 SSH 密钥

        按照此处的说明进行操作:

        https://docs.github.com/en/enterprise-server@2.19/github/authenticating-to-github/connecting-to-github-with-ssh

        ...但是关于使用 ssh 进行身份验证,我想说的要点是关于 git 配置文件 .git/config(在您的存储库中)。您可能会看到类似于以下的一行:

        [remote "origin"]
            url = https://github.com/smartsendio/pickup-map.git
            fetch = +refs/heads/*:refs/remotes/origin/*
        

        注意上面的url 行...必须更改为:

            url = git@github.com:smartsendio/pickup-map.git
        

        ...您可以从 GitHub 存储库的代码按钮中复制/粘贴值:

        【讨论】:

          猜你喜欢
          • 2023-03-22
          • 2017-04-18
          • 2022-08-19
          • 2019-06-18
          • 2021-01-26
          • 1970-01-01
          • 1970-01-01
          • 2020-10-24
          • 2018-10-09
          相关资源
          最近更新 更多