AI Tools Guide

Git Authentication Failed Fix Mistakes

git 报 Authentication failed / could not read Username,是因为 GitHub 早已停用密码认证。给出用 Personal Access Token、SSH 密钥、清理旧凭据的真实步骤,区分 HTTPS 和 SSH 两条路。

What is the problem?

git 报 Authentication failed / could not read Username,是因为 GitHub 早已停用密码认证。给出用 Personal Access Token、SSH 密钥、清理旧凭据的真实步骤,区分 HTTPS 和 SSH 两条路。

Quick solution

Treat this as a GitHub troubleshooting issue. First confirm the environment, inputs, permissions, logs, and delivery boundary. Then use the linked deep guide for the full checklist before changing production code or promising a result.

Read the deep guide

Detailed steps

  1. GitHub → Settings → Developer settings → Personal access tokens → 生成一个(勾上 `repo` 权限)。
  2. push 时用户名填 GitHub 用户名,**密码处粘贴这个 token**。
  3. 想免每次输入,用凭据管理器缓存:
  4. Windows:控制面板 → 凭据管理器 → Windows 凭据,删掉 github 相关条目。
  5. macOS:钥匙串访问搜 `github.com` 删掉旧条目。
  6. 通用:`git config --global --unset credential.helper` 后重新认证。

Commands or code

git remote -v
# https://github.com/... → 走 HTTPS + PAT(见一)
# git@github.com:...     → 走 SSH 密钥(见二)

Risk notes

Confirm the real project environment, account permissions, platform rules, and output quality before delivery. Do not ship AI-generated changes without human review, and do not claim indexing, income, deployment success, or ranking improvements without measured evidence.