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

相关推荐
cen__y5 小时前
Linux12(Git01)
linux·运维·服务器·c语言·开发语言·git
海蓝可知天湛6 小时前
Agent&IELTS雅思口语专属语料库
人工智能·github·rag·ielts·skills
ServBay7 小时前
OpenCode 和它的7款必备插件
后端·github·ai编程
Yunzenn8 小时前
字节最新研究cola-DLM第 01 章:语言生成的三次范式之争 —— 从 RNN 到 AR 到扩散
架构·github
wangruofeng8 小时前
GitHub AI 月榜解读:8 大趋势告诉你该关注什么
github·ai编程
bukeyiwanshui8 小时前
20260518 Swift实验
git·swift
qziovv8 小时前
Git 回退场景
大数据·git·elasticsearch
小小测试开发11 小时前
AI 水印攻防战:OpenAI 引入 SynthID 认证,GitHub 同步出现去水印工具
人工智能·github
来自大山深处的Doge_11 小时前
解决Git提交更新更改时出错: detected dubious ownership in repository at ...
git
微软技术栈12 小时前
Microsoft AI Genius 4.0 | 使用 GitHub Copilot SDK 升级开发者体验
人工智能·microsoft·github