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

相关推荐
fpcc5 小时前
工具使用—git add命令分析说明
git·工具
问天_观心8 小时前
零基础在windows环境下的WSL使用llamafactory(二)
人工智能·神经网络·语言模型·github·模型蒸馏
逛逛GitHub10 小时前
AI 时代 Markdown 又火了,7 款 GitHub 高赞开源编辑器。
github
独隅10 小时前
VS Code Git 工作树多分支并行开发实战指南
大数据·git·elasticsearch
u13013010 小时前
GitHub 热榜项目:日榜(2026-08-18)
github
峰向AI11 小时前
5万多人点赞的下载工具,凭什么让我放下了用了三年的老软件
github
小玮看世界13 小时前
AtomGit 429 报错引发的思考:从“未授权限流”看开源平台的“浏览权”博弈
开源·github
m4Rk_15 小时前
【论文阅读】Agent 记忆机制(43):Mem²Evolve——让经验与能力在双记忆中共同进化
论文阅读·人工智能·学习·开源·github
CuSn16 小时前
我做了一个非官方 DeepSeek Harness 工具箱:插件、启动器和可验证目录
github