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

Mac升级Ventura后Bitbucket Git拉取失败:Permission denied (publickey)

Mac Ventura升级后Bitbucket SSH拉取代码失败(Permission denied (publickey))

问题概述

升级Mac到Ventura系统后,从Bitbucket拉取代码时出现如下错误:

git@code.pruconnect.net: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

已尝试删除旧SSH密钥并添加新密钥、将密钥加入ssh-agent,但问题未解决。执行ssh -T git@bitbucket.org仍返回权限拒绝,ssh -vT git@bitbucket.org的调试日志显示SSH客户端已提供两个密钥,但均被服务器拒绝。

解决方案

1. 确认公钥已正确添加到对应Bitbucket平台

  • 查看本地公钥内容:
    cat ~/.ssh/id_rsa.pub
    cat ~/.ssh/amijeet.thakur@wedopulse.co.in.pub
    
  • 注意:你的拉取错误指向code.pruconnect.net(可能是企业内部Bitbucket Server),而非公共Bitbucket.org。登录对应的Bitbucket平台,进入个人设置→SSH密钥页面,确认上述公钥已完整添加(包括末尾的邮箱注释),且未过期。

2. 修复.ssh目录及密钥文件权限

Ventura系统对文件权限要求严格,错误的权限会导致SSH无法读取密钥。执行以下命令修正:

chmod 700 ~/.ssh
chmod 600 ~/.ssh/id_rsa
chmod 600 ~/.ssh/amijeet.thakur@wedopulse.co.in
chmod 644 ~/.ssh/id_rsa.pub
chmod 644 ~/.ssh/amijeet.thakur@wedopulse.co.in.pub
chmod 644 ~/.ssh/known_hosts

3. 检查SSH配置文件

查看~/.ssh/config的内容,确认针对code.pruconnect.net的配置是否正确:

  • 是否指定了错误的IdentityFile路径
  • 是否存在冲突的配置项(如PubkeyAuthentication no)
    若不确定,可先备份该文件,删除相关配置后重新测试ssh -T git@code.pruconnect.net。

4. 重新启动ssh-agent并添加密钥

执行以下命令重启ssh-agent并重新加载密钥:

eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_rsa
ssh-add ~/.ssh/amijeet.thakur@wedopulse.co.in

完成后再次测试连接:ssh -T git@code.pruconnect.net

5. 生成新的ED25519密钥(推荐)

Ventura自带的OpenSSH 9.0对ED25519密钥支持更好,可尝试生成新密钥:

ssh-keygen -t ed25519 -C "amijeet.thakur@wedopulse.co.in"

将生成的~/.ssh/id_ed25519.pub内容添加到Bitbucket账户,再通过ssh-add ~/.ssh/id_ed25519加入ssh-agent,测试连接。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.13 00:05:25