You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Mac Sequoia更新后Git SSH连GitHub遇Permission denied (publickey)求助

SSH密钥连接GitHub突然失败(Mac Sequoia 15.3.2更新后)

此前一直通过SSH密钥实现本地Git与GitHub的连接,Mac系统更新至Sequoia 15.3.2后,突然无法推送(push)或拉取(pull)远程仓库,删除并重新生成SSH密钥后问题仍未解决。终端报错如下:

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.

以下是实用排查和解决建议:

  • 重启SSH代理并添加密钥:Mac系统更新可能重置了ssh-agent,执行以下命令重新启动并加载密钥:
    eval "$(ssh-agent -s)"
    ssh-add ~/.ssh/id_rsa  # 替换为你的密钥文件名,比如id_ed25519
    
  • 验证SSH连接有效性:执行ssh -T git@github.com,根据返回信息定位具体问题(比如密钥未被识别、网络连通性问题等)。
  • 检查SSH配置文件:查看~/.ssh/config是否存在针对github.com的配置,确保指定了正确的密钥路径,示例配置如下:
    Host github.com
      HostName github.com
      User git
      IdentityFile ~/.ssh/id_rsa  # 对应你的密钥文件
      IdentitiesOnly yes
    
  • 确认GitHub公钥匹配:重新复制本地公钥内容(cat ~/.ssh/id_rsa.pub),粘贴到GitHub账户的SSH密钥列表中,确保无多余空格或换行。
  • 修复文件权限:Mac系统更新可能修改了~/.ssh目录或密钥文件的权限,执行以下命令恢复正确权限:
    chmod 700 ~/.ssh
    chmod 600 ~/.ssh/id_rsa
    
  • 临时切换HTTPS验证:如果SSH问题暂无法解决,可临时切换远程仓库地址为HTTPS,排除仓库权限本身的问题:
    git remote set-url origin https://github.com/你的用户名/你的仓库名.git
    

内容的提问来源于stack exchange,提问作者albeit2

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.13 18:32:36