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

相关推荐
wangruofeng4 小时前
opencodex 解锁 Codex 任意模型,一个本地代理打通 Claude/Kimi/GLM/DeepSeek
llm·github·openai
是宇写的啊5 小时前
Git远程操作
git
一点一木6 小时前
从60首歌到1个网站:输入你的故事,还你一首歌
前端·github
刘较瘦_10 小时前
AI 开发中的 Git Submodule 父子仓库模式:前后端分仓管理与协作实践
前端·github
DeMinds13 小时前
内容没有丢,我为什么总在重新整理?|DeMinds 如何让工作接着继续
ios·github·markdown
寒水馨13 小时前
macOS下载、安装openclaw-v2026.7.1(附安装包OpenClaw-2026.7.1.dmg)
macos·大模型·github·开源软件·ai助手·openclaw·gpt-5.6
our_times14 小时前
# Git 高频命令实战指南:从日常开发到进阶协作
git
徐小夕14 小时前
花了3天,我写了一款开源AI公众号编辑器
前端·vue.js·github
PBitW14 小时前
git 中容易遗忘的点 (二) ⚡⚡⚡
前端·git·面试