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

相关推荐
无奈笑天下8 小时前
Linux上kdump故障标准处理流程
linux·运维·服务器·github
李永奉9 小时前
Git和GitHub-用操作命令控制Git的工作区、暂存区、本地仓库之间状态的提交教程
git·github
用户693717500138411 小时前
AI 越强,为什么我们反而越来越担心失业?
前端·后端·github
羊在吃青草14 小时前
Git之远程仓库
git
粥里有勺糖14 小时前
视野修炼-技术周刊第138期 | 不要让 AI 代表你
前端·github·aigc
小帅不太帅16 小时前
Gemini 4 很顺手,但 agy CLI 看不见上下文和额度,我做了个开源状态栏
github·agent
一条Go17 小时前
ent + PostgreSQL:部分唯一索引怎么表达「全表最多一个」
后端·github
一条Go17 小时前
开源新生代雷达 · 第 21 期
github
wflynn19 小时前
GitHub 今日推荐|xcl:在 Windows PC 上直接运行 Xbox Series X|S 游戏
rust·开源·github·d3d12·gdk·rdna2
逛逛GitHub19 小时前
本周 TOP 11 排名的 GitHub 开源项目大盘点,看看能用到哪些。
github