解决 Git 克隆报错Password authentication is not supported当使用 Git 克隆 GitHub 仓库时若遇到Password authentication is not supported错误表明 GitHub 已不再支持账号密码的 HTTPS 认证方式。以下是两种彻底解决方案方案一改用 SSH 连接推荐SSH 方式配置后无需重复输入密码适合长期开发。生成 SSH Key执行以下命令生成密钥替换为你的 GitHub 邮箱ssh-keygen -t ed25519 -C your_emailexample.com若系统不支持ed25519改用ssh-keygen -t rsa -b 4096 -C your_emailexample.com默认密钥路径为~/.ssh/。添加公钥到 GitHub复制公钥内容Windows (Git Bash):cat ~/.ssh/id_ed25519.pub | clipMac:pbcopy ~/.ssh/id_ed25519.pubLinux:xclip -sel clip ~/.ssh/id_ed25519.pub登录 GitHub进入Settings - SSH and GPG keys - New SSH key粘贴公钥并保存。使用 SSH 地址克隆将 HTTPS 链接改为 SSH 格式git clone gitgithub.com:xxx/xxxx.git方案二继续使用 HTTPS 并替换为 Token若需使用 HTTPS需生成 Personal Access Token (PAT) 替代密码。生成 Token登录 GitHub进入Settings - Developer settings - Personal access tokens - Tokens (classic)。点击Generate new token (classic)设置备注和过期时间勾选repo权限。生成后立即复制 Token如ghp_xxxxx关闭页面后无法再次查看。使用 Token 克隆执行克隆命令git clone https://github.com/xxx/xxxx.gitUsername: 输入 GitHub 用户名。Password: 粘贴 Token输入时无显示直接回车。权限问题排查若仍报错Repository not found检查仓库是否为私有在浏览器无痕模式访问仓库链接若显示 404 则为私有仓库。确认是否有访问权限联系仓库所有者添加你的账号至Settings - Collaborators。方案对比方案优点适用场景SSH长期有效无需重复认证频繁代码推送或长期开发HTTPS Token配置简单临时操作或网络限制 SSH 时优先选择 SSH 方案以获得更流畅的 Git 体验。