[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

相关推荐
wangruofeng12 小时前
opencodex 解锁 Codex 任意模型,一个本地代理打通 Claude/Kimi/GLM/DeepSeek
llm·github·openai
一点一木14 小时前
从60首歌到1个网站:输入你的故事,还你一首歌
前端·github
刘较瘦_18 小时前
AI 开发中的 Git Submodule 父子仓库模式:前后端分仓管理与协作实践
前端·github
DeMinds21 小时前
内容没有丢,我为什么总在重新整理?|DeMinds 如何让工作接着继续
ios·github·markdown
寒水馨21 小时前
macOS下载、安装openclaw-v2026.7.1(附安装包OpenClaw-2026.7.1.dmg)
macos·大模型·github·开源软件·ai助手·openclaw·gpt-5.6
徐小夕1 天前
花了3天,我写了一款开源AI公众号编辑器
前端·vue.js·github
CCPC不拿奖不改名2 天前
大模型推理架构与开源生态知识整理
数据库·windows·python·架构·langchain·开源·github
redreamSo2 天前
一天涨 1800 星的 GitHub 榜首:AI 编程瓶颈变成了 token
人工智能·开源·github
小弥儿2 天前
GitHub今日热榜 | 2026-07-20:AI Agent 知识体系迎来系统化梳理
学习·开源·github