一、问题现象
2025 年 4 月 21 日,有用户反馈在将 GitLab 升级至 17.11.0 版本后,通过 HTTPS 协议执行 git clone 等命令行操作时遇到权限问题。具体表现为:
- 网页端登录正常:使用相同的用户名和密码可正常访问 GitLab 网页端。
- 命令行操作失败:通过命令行执行 HTTPS 相关的 Git 操作(如克隆代码库)时,提示以下错误:
remote: HTTP Basic: Access denied. If a password was provided for Git authentication, the password was incorrect or you're required to use a token instead of a password. If a token was provided, it was either incorrect, expired, or improperly scoped.
该错误表明身份验证失败,可能与密码错误、令牌失效或权限范围配置不当有关。
解决方案
17.11 版本包含的一个合并请求(MR)导致若 GitLab 实例没有个人访问令牌前缀,将不再回退检查是否使用密码登录。有两个解决方法:
- 一是在管理面板的 “Settings -> General -> Account and Limit” 中,给 “Personal
access token prefix” 字段填写有效前缀(默认是 “glpat-”); - 二是使用上述 MR
链接中的功能切换,禁用相关功能(通过:prevent_token_prefixed_password_fallback_sessionless标志),不过这可能不是长期解决方案。
Comments | NOTHING