cocoapods之git push 输入username和password后提示remote: Support for password authentica

100 阅读2分钟

cocoapods之git push 输入username和password后提示remote: Support for password authentication was removed on August 13, 2021.remote: Please see docs.github.com/get-started… for information on currently recommended modes of authentication.

fatal: Authentication failed for 'github.com/AndyJackChe…'

GitHub在2021年8月13日之后移除了通过密码进行身份验证的支持。这意味着当你尝试使用HTTPS URL和密码进行Git操作(如git push或git clone)时,会收到如下错误信息:

remote: Support for password authentication was removed on August 13, 2021.

remote: Please see docs.github.com/en/get-star… for information on currently recommended modes of authentication.

fatal: Authentication failed for 'github.com/xxx/xxx.git…'

为了解决这个问题,你需要使用以下推荐的身份验证方式之一:

  1. 个人访问令牌(Personal Access Token, PAT)

git push https://<your_token>@github.com//.git/

  • 或者,你可以更新远程URL以包含令牌:

git remote set-url origin https://<your_token>@github.com//.git/

  1. SSH密钥
  • 生成SSH密钥对:如果你还没有SSH密钥对,可以使用以下命令生成:

ssh-keygen -t rsa -b 4096 -C "your_email@example.com"

  • 将公钥添加到GitHub账户:将生成的公钥(通常是\~/.ssh/id_rsa.pub)复制并粘贴到GitHub的SSH密钥设置中。

  • 更新远程URL以使用SSH:将远程URL从HTTPS更改为SSH格式。例如:

git remote set-url origin git@github.com:/.git

  1. GitHub CLI
  • 安装GitHub CLI:如果你还没有安装GitHub CLI,可以从GitHub CLI页面下载并安装。
  • 使用GitHub CLI进行身份验证:运行gh auth login命令并按照提示进行操作。

通过以上方法,你可以解决由于密码认证被移除而导致的Git身份验证失败问题。推荐使用个人访问令牌或SSH密钥,因为它们比密码更安全,并且是GitHub当前推荐的身份验证方式。