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

相关推荐
脆皮炸鸡7551 小时前
Linux开发工具~~~版本控制器Git以及调试工具GDB
linux·服务器·开发语言·经验分享·git·学习方法
起个名字总是说已存在2 小时前
github开源AI 拓展工具:Agent Reach
人工智能·github·dreamweaver
小雨青年3 小时前
GitHub Copilot 默认启用训练之后 企业安全如何应对
安全·github·copilot
console.log('npc')3 小时前
团队协作提交自己的功能
git
独隅4 小时前
开源项目 Git 贡献全流程的完整拆解:从 Fork 到 PR
git·开源
攀登的牵牛花5 小时前
2.1w Star 的 pretext 火在哪?
前端·github
糖猫猫_5 小时前
Kite 实现逻辑删除
后端·github
一叶萩Charles5 小时前
GitHub AI Agent 开源生态概览
人工智能·开源·github
___波子 Pro Max.5 小时前
Git Rebase: HEAD~ 的简洁写法
git
bxri5 小时前
团队协作中的 Git 工作流(企业级实战)
git·gitee·github