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

Zorin/Ubuntu系统GitHub PAT推送远程仓库403权限错误排查

运行环境
  • 操作系统:Zorin
问题描述

通过SSH命令克隆GitHub公有仓库:git clone git@github.com:Organization_Name/Repo_Name.git,本地创建新分支后执行git push --set-upstream origin My_Branch尝试将分支推送到远程仓库时,系统弹出了HTTPS协议的账号密码输入提示:

Username for 'https://github.com': qingqing0226
Password for 'https://qingqing0226@github.com': My_Token

说明:使用的个人访问令牌(PAT)生成时已勾选全部权限,不存在权限范围配置不足的问题。

输入账号和令牌后系统直接返回403错误:

remote: Permission to Organization_Name/Repo_Name.git denied to qingqing0226.
fatal: unable to access 'https://github.com/Organization_Name/Repo_Name.git/': The requested URL returned error: 403

多次重试推送均返回相同错误,最初怀疑是令牌输入错误,将令牌粘贴到文本文件逐字符核对后,确认内容完全准确,不存在末尾多空格、字符输错等问题。
执行git config -l查看本地Git配置信息如下:

user.email=My_Email
user.name=qingqing0226
user.password=My_Token
credential.helper=store
url.git@github.com:.insteadof=https://github.com/
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
remote.origin.url=git@github.com:Organization_Name/Repo_Name.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.main.remote=origin
branch.main.merge=refs/heads/main
排查过程
  • 首次排查时切换为纯SSH方式推送,之前的HTTPS 403错误不再触发,但首次连接GitHub服务时弹出主机真实性校验提示,输入yes确认添加主机指纹后,返回了新的权限错误:
The authenticity of host 'github.com (140.82.121.4)' can't be established.
ECDSA key fingerprint is SHA256:p2QAMXNIC1TJYWeIOttrVc98/R1BUFWu3/LiyKgUfQM.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'github.com,140.82.121.4' (ECDSA) to the list of known hosts.
ERROR: Permission to Organization_Name/Repo_Name.git denied to qingqing0226.
fatal: Could not read from remote repository.

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

该报错明确指向当前账号对目标仓库无写入权限。

  • 后续逐一核查SSH密钥配置、个人访问令牌权限、操作系统环境、Git本地配置,均未发现异常。
最终解决方案

GitHub公有仓库默认仅对仓库所属组织的授权成员开放直接写入权限,外部用户无协作者权限时无法直接向原仓库推送分支。通过Fork目标仓库到个人账号下的方式,即可正常推送分支,后续再向原仓库提交Pull Request完成代码贡献,按该方式操作后推送正常,问题彻底解决。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.28 18:42:21