当前位置: 首页 > news >正文

GIT ---- 解决【fatal: Authentication failed for】

1. 报错

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

remote: Please see https://docs.github.com/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.

fatal: Authentication failed for

2. 错误解释

GitHub 自 2021 年 8 月 13 日起不再支持密码认证,你需要采用其他认证方式,比如使用个人访问令牌(Personal Access Token)或者 SSH 密钥。

3. 解决办法

  1. 使用个人访问令牌(Personal Access Token);
  2. 使用 SSH 密钥。

4. 使用个人访问令牌(Personal Access Token)

4.1 生成个人访问令牌
  1. 登录你的 GitHub 账号,点击右上角的头像,选择 “Settings”。
  2. 在左侧菜单中,点击 “Developer settings”。
  3. 选择 “Personal access tokens”,然后点击 “Generate new token”。
  4. 给令牌命名,选择需要的权限(一般克隆仓库选择 repo 权限即可),设置令牌的过期时间。
  5. 点击 “Generate token” 生成令牌,注意要及时保存这个令牌,因为页面刷新后就无法再次查看。
4.2 使用令牌进行认证

在命令行中,当你进行 git push 或者 git clone 操作时,将原来使用的密码替换为个人访问令牌。
例如,克隆仓库时:

git clone https://github.com/xxx/xxx.git

在输入密码的提示处,输入你刚才生成的个人访问令牌。

4.3 更新本地仓库的认证信息(可选)

如果你之前已经克隆了仓库,并且使用的是旧的认证方式,可以通过以下命令更新认证信息:

git remote set-url origin https://<your-github-username>:<your-personal-access-token>@github.com/xxx/xxx.git

将 your-github-username 替换为你的 GitHub 用户名, your-personal-access-token 替换为你生成的个人访问令牌。

5. 使用 SSH 密钥

5.1 生成 SSH 密钥

打开终端,输入以下命令生成 SSH 密钥:

ssh-keygen -t ed25519 -C "your_email@example.com"

将 your_email@example.com 替换为你在 GitHub 上注册的邮箱地址。按照提示完成密钥生成过程,生成的密钥默认存储在 ~/.ssh/id_ed25519 和 ~/.ssh/id_ed25519.pub 。

5.2 添加 SSH 密钥到 GitHub
  1. 复制公钥内容:
cat ~/.ssh/id_ed25519.pub
  1. 登录 GitHub,点击右上角的头像,选择 “Settings”。
  2. 在左侧菜单中,点击 “SSH and GPG keys”。
  3. 点击 “New SSH key”,将复制的公钥内容粘贴到 “Key” 字段,给密钥命名,然后点击 “Add SSH key”。
5.3 使用 SSH 地址克隆仓库
  1. 将原来使用的 HTTPS 地址替换为 SSH 地址进行克隆:
git clone git@github.com:xxx/xxx.git
  1. 删除原来的远程库,添加新的 SSH 地址:
git remote remove origin
git remote add origin git@github.com:xxx/xxx.git
git push -u origin master -f

完美解决!!!

http://www.dtcms.com/a/108374.html

相关文章:

  • 【案例89】达梦数据库优化器参数导致的SQL执行错误
  • 在Ubuntu20.04开发Dify插件教程,部署Dify插件脚手架
  • 深度学习 Deep Learning 第15章 表示学习
  • 针对 MySQL 数据库的详细说明,分类列出临时资源(临时表、游标、未提交事务、会话变量、预编译语句)的创建、清理方式及未清理后果,并以表格总结
  • [CH32] RISC-V汇编指令解释
  • linux下springboot项目守护进程编写
  • arm64平台下linux访问寄存器
  • Python----机器学习(线性回归:前向传播和损失函数)
  • 【C++基础知识】 C 预处理器中的 #line 指令详解
  • RabbitMQ应用2
  • Linux系统之SFTP-搭建SFTP服务器
  • ui-tars和omni-parser使用
  • JavaScript 模块化详解( CommonJS、AMD、CMD、ES6模块化)
  • 网络安全-等级保护(等保) 1-0 等级保护制度公安部前期发文总结
  • 蓝桥杯 web 表格数据转化(组件挂载、模板字符串)
  • 【硬件视界9】网络硬件入门:从网卡到路由器
  • C# 扩展方法
  • 跨网连接vscode
  • 银联三级等保定级报告
  • CMake学习--Window下VSCode 中 CMake C++ 代码调试操作方法
  • 闭环SOTA!北航DiffAD:基于扩散模型实现端到端自动驾驶「多任务闭环统一」
  • 面基spring如何处理循环依赖问题
  • conda 清除 tarballs 减少磁盘占用 、 conda rename 重命名环境、conda create -n qwen --clone 当前环境
  • 机器学习、深度学习和神经网络
  • vscode调试python(transformers库的llama为例)
  • C#实现HiveQL建表语句中特殊数据类型的包裹
  • 用docker部署goweb项目
  • RainbowDash 的 Robot
  • C++学习笔记(三十一)——map
  • Git的基础使用方法