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

相关推荐
DW_DROME41 分钟前
git worktree (镜像站加速)
git
赵文宇(温玉)5 小时前
构建内网离线的“github.com“,完美解决内网Go开发依赖
开发语言·golang·github
牛奶咖啡135 小时前
利用Github与Hexo搭建属于自己的在线个人博客
github·hexo创建静态博客·免费部署博客到公网上·创建自定义静态博客·将静态博客上传到github·将自己的网站发布到网上
散峰而望5 小时前
C++入门(一)(算法竞赛)
c语言·开发语言·c++·编辑器·github
qq_5470261796 小时前
OAuth 2.0 安全授权
git·安全·github
GOATLong7 小时前
git使用
大数据·c语言·c++·git·elasticsearch
uhakadotcom10 小时前
基于 TOON + Next.js 来大幅节省 token 并运行大模型
前端·面试·github
孟陬10 小时前
别再社死了!`includeIf` 一招搞定 Git 提交者信息错乱,守护你的邮箱隐私
git·github
Cyril_KI12 小时前
大模型长文生成中的幻觉与事实性:研究进展综述
大模型·llm·github·综述·幻觉
lyj16899712 小时前
git小乌龟如何单个文件回退及整个版本回退
git