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

相关推荐
maply4 小时前
VSCode 中的 Git Graph扩展使用详解
ide·git·vscode·编辑器·扩展
时光追逐者8 小时前
Visual Studio使用GitHub Copilot提高.NET开发工作效率
c#·github·.net·copilot·ai编程·微软技术·visual studio
行十万里人生8 小时前
Qt事件处理:理解处理器、过滤器与事件系统
开发语言·git·qt·华为od·华为·华为云·harmonyos
会敲代码的Steve11 小时前
git笔记-简单入门
笔记·git
画船听雨眠aa13 小时前
gitlab云服务器配置
服务器·git·elasticsearch·gitlab
油泼辣子多加15 小时前
2025年02月01日Github流行趋势
github
萨文 摩尔杰16 小时前
hexo部署到github page时,hexo d后page里面绑定的个人域名消失的问题
github
Tangcan-1 天前
Linux中基础开发工具(yum,vim,gcc/g++,git,gdb/cgdb)
linux·git·vim
苏-言1 天前
Git进阶之旅:分支管理策略
git
油泼辣子多加1 天前
2025年01月31日Github流行趋势
github