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

相关推荐
逛逛GitHub8 小时前
发现一个 AI 大模型服务质量榜单。
github
权咚9 小时前
阿权的开发经验小集
git·ios·xcode
就是帅我不改11 小时前
揭秘Netty高性能HTTP客户端:NIO编程的艺术与实践
后端·面试·github
uhakadotcom13 小时前
静态代码检测技术入门:Python 的 Tree-sitter 技术详解与示例教程
后端·面试·github
绝无仅有15 小时前
数据库MySQL 面试之死锁与排查经验总结
后端·面试·github
绝无仅有16 小时前
mysql性能优化实战与总结
后端·面试·github
杨杨杨大侠16 小时前
解密 atlas-mapper 框架 (9/10):故障排查与调试技巧
java·开源·github
徐小夕17 小时前
花了一天时间,开源了一套精美且支持复杂操作的表格编辑器tablejs
前端·算法·github
HelloGitHub18 小时前
终端里跑图形应用「GitHub 热点速览」
开源·github
数字化顾问1 天前
GitHub热榜项目 - 日榜之应用场景与未来发展趋势
github