git push报错git@github.com: Permission denied (publickey).

c 复制代码
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
  • 已经使用git config设置邮箱和密码,可以说使用git config --list查看,用ssh-keygen生成密钥x_github_idrsa,并将x_github_idrsa.pub内容复制进github
c 复制代码
Generating public/private rsa key pair.
Enter file in which to save the key (/home/x/.ssh/id_rsa): x_github_idrsa
  • 使用ssh_add报错
c 复制代码
ssh-add ~/.ssh/x_github_idrsa
Could not open a connection to your authentication agent.
正确案例:Identity added:xxxxxx

正确处理方法

https://stackoverflow.com/questions/17846529/could-not-open-a-connection-to-your-authentication-agent

  • 先打开ssh_add,再添加密钥就可以使用git push了
c 复制代码
eval `ssh-agent -s`
ssh-add
ssh-add ~/.ssh/x_github_idrsa

参考文章Git使用出现git@github.com: Permission denied (publickey). 处理https://blog.csdn.net/qq_43768946/article/details/90411154

用一下git push能出这么多问题是没想到的,stackoverflow还是好用
https://stackoverflow.com/questions/13509293/git-fatal-could-not-read-from-remote-repository

实在不行删除.ssh文件夹里的known_hosts,每次连接应该会重新生成,要不删除ssh_key再重新生成复制进github

相关推荐
Irene19912 小时前
查看是否已安装 Git 的方法
git
my_power5202 小时前
检出git项目到android studio该如何配置
android·git·android studio
安果移不动2 小时前
Git 实战:如何优雅地撤销历史中的某一个 Commit?
git
周杰伦_Jay2 小时前
【大模型数据标注】核心技术与优秀开源框架
人工智能·机器学习·eureka·开源·github
吴敬悦5 小时前
私有的 GitHub Package 怎么拉取?
npm·github
啥都不懂的小小白5 小时前
Git 入门指南:从零开始掌握版本控制
git
AI逐月5 小时前
Git 彻底清除历史记录
大数据·git·elasticsearch
有什么东东6 小时前
Windows安装git教程以及初步使用
git
不爱吃米饭_6 小时前
Gitea 轻量级的Git方案 - Gitlab的替代品
git·gitlab·gitea
小胖霞8 小时前
全栈系列(15)github Actions自动化部署前端vue
前端·node.js·github