[Solution] Github Permission denied (publickey)

出现 "Permission denied (publickey)" 说明本地 SSH 公钥没被 GitHub 认可或没被 ssh-agent 使用。

按步骤排查(在 Git Bash):

  1. 检查是否已有密钥
bash 复制代码
ls ~/.ssh
# 常见文件:id_ed25519 / id_rsa 及对应 .pub
  1. 如无密钥则生成(推荐 ed25519)
bash 复制代码
ssh-keygen -t ed25519 -C "你的邮箱"
# 一路回车,生成 ~/.ssh/id_ed25519 和 id_ed25519.pub
  1. 启动 ssh-agent 并添加私钥
bash 复制代码
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519
  1. 把公钥加入 GitHub
bash 复制代码
cat ~/.ssh/id_ed25519.pub

复制输出,在 GitHub → Settings → SSH and GPG keys → New SSH key 粘贴保存。

  1. 测试连接

  2. 再次推送

成功*★,°*:.☆( ̄▽ ̄)/.°★* 。

tips: 如果 ssh-add 报错或重启后失效,可在当前会话先执行 eval "$(ssh-agent -s)"ssh-add

相关推荐
极光技术熊9 小时前
Spring AI 从入门到精通:构建你的 AI 开发知识体系
后端·github
用户394839510755310 小时前
怎么让我的 Agent 真正"懂"我?——关于记忆、经验学习与预测的一些真实体验
github
远航_16 小时前
git submodule
前端·后端·github
fthux17 小时前
如果你用 Mac,那你可能需要 Noti Shift
macos·开源·github
程序员天天困1 天前
Loop Engineering 实战:/goal 命令让 AI 自己写完整项目
github
徐小夕1 天前
我们开源了一款“框架无关”的思维导图编辑器,3分钟集成到任意系统
前端·javascript·github
小爷毛毛_卓寿杰1 天前
我把 397B 的「Agentic 大脑」塞进了 Xinference,一键部署 Nex-N2
人工智能·架构·github
小爷毛毛_卓寿杰2 天前
我把一个 3B 模型塞进了 Xinference,然后它干掉了 DeepSeek V3.2
人工智能·开源·github
凌奕2 天前
别用文档约束你的 Agent:聊聊 Agent 开发流程的思想
llm·github·agent
HelloGitHub2 天前
《HelloGitHub》第 123 期
开源·github