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

GitLab端口2222克隆有权限仓库失败问题求助

解决Git通过2222端口克隆仓库的权限/不存在报错

问题重现

执行克隆命令:

git clone git@<address>:2222/<user>/<repo>.git

出现报错:

Cloning into '<repo_name>'...
remote:
remote: ========================================================================
remote:
remote: 您查找的项目不存在或您无查看权限。
remote:
remote: ========================================================================
remote:
fatal: Could not read from remote repository.

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

解决方案

  • 修正SSH端口写法:Git的SSH地址里,冒号:默认用来分隔主机和仓库路径,不是端口标识。带端口的正确写法需要加上ssh://前缀:
    git clone ssh://git@<address>:2222/<user>/<repo>.git
    
  • 配置SSH简化连接:不想每次输入完整前缀的话,编辑本地SSH配置文件(Linux/macOS路径为~/.ssh/config,Windows路径为C:\Users\<你的用户名>\.ssh\config),添加:
    Host <address>
        Port 2222
        User git
    
    保存后直接用简化命令克隆:
    git clone <address>:<user>/<repo>.git
    
  • 验证SSH连接有效性:先执行以下命令测试端口和权限是否正常:
    ssh -p 2222 git@<address>
    
    如果能成功连接并看到仓库服务的欢迎信息,说明端口和密钥配置没问题;如果连接失败,排查服务器端口是否开放、本地SSH密钥是否已添加到仓库平台账号中。
  • 核对仓库地址:确认<user>和<repo>的拼写完全正确,避免因地址错误导致“项目不存在”的提示。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.19 01:01:11