GitLab 安装上后git clone时出现403 404错误的解决方法

本文介绍了如何解决GitLab部署中出现的403 Forbidden及404 Not Found错误。对于403错误,通过调整文件权限可以解决;而对于404错误,则需要检查并配置正确的URL。
Stable-Diffusion-3.5

Stable-Diffusion-3.5

图片生成
Stable-Diffusion

Stable Diffusion 3.5 (SD 3.5) 是由 Stability AI 推出的新一代文本到图像生成模型,相比 3.0 版本,它提升了图像质量、运行速度和硬件效率

1. 403

http://stackoverflow.com/questions/21635299/try-install-gitlab-6-5-stable-but-have-a-403-forbiden

warning: Insecure world writable dir /home/git/gitlab/vendor/bundle/ruby/1.9.1/bin in PATH, mode 042777

It seems you have some issues with the permissions being too open. Fix that by going to /home/git/gitlab/ and run:

  • find . -type f -print0 | xargs -0 chmod 644 (all files 644 recursively)
  • find . -type d -print0 | xargs -0 chmod 755 (all directories 755 recursively)
  • sudo -u git -H chmod o-rwx config/database.yml (extra security for the database)

If that is not the case then maybe its SELinux. You can check that quickly by disabling it temporarily:

setenforce 0

If the 403 error goes away then enable it back (setenforce 1) and see here at the SELinux section how to make it work.



2.404

http://stackoverflow.com/questions/21327907/check-gitlab-api-access-failed-code-404


A simple search - https://github.com/gitlabhq/gitlab-shell/issues/37 reveals that URL set in config.yml for gitlab-shell is incorrect and causes 404 error.

Make sure the config.yml for gitlab-shell is pointing at the correct url or a url that your web server is configured to listen for (eg, probably not localhost).


404错误是由于"/usr/bin/git"程序没找到,所能用命令:ln /usr/local/bin/git /usr/bin/git,问题得到解决。





您可能感兴趣的与本文相关的镜像

Stable-Diffusion-3.5

Stable-Diffusion-3.5

图片生成
Stable-Diffusion

Stable Diffusion 3.5 (SD 3.5) 是由 Stability AI 推出的新一代文本到图像生成模型,相比 3.0 版本,它提升了图像质量、运行速度和硬件效率

在使用 `git clone` 命令克隆远程仓库,有会遇到如下错误: ``` FATAL ERROR: Subsystem request failed on channel 0 scp: Connection closed ``` 此错误通常与 SSH 配置或远程服务器的 SSH 子系统设置有关,尤其是在使用 SSH 协议连接 Git 仓库(如 GitHub、GitLab、自建 Git 服务器等)发生。以下是可能的原因及对应的解决方案: ### 1. SSH 子系统配置问题 某些 Git 服务器(尤其是自建 Git 服务器)在 SSH 配置中未正确设置 `git-upload-pack` 或 `git-receive-pack` 子系统路径,导致 SSH 客户端无法正确执行 Git 操作。 **解决方案:** - 确保远程服务器上的 `~/.ssh/config` 或 `/etc/ssh/sshd_config` 中正确配置了子系统路径,例如: ```bash Subsystem git /usr/lib/git-core/git-upload-pack ``` - 如果使用的是自定义用户(如 `git` 用户),请确保该用户的 `.ssh/authorized_keys` 文件中没有限制子系统执行权限。 - 可尝试手动测试 SSH 子系统是否正常: ```bash ssh -T git@your-git-server ``` 如果返回权限拒绝或路径错误,说明子系统配置有问题[^1]。 ### 2. SSH 密钥配置问题 如果 SSH 密钥未正确配置或未被 Git 使用,也可能导致连接失败。 **解决方案:** - 检查 SSH 密钥是否已添加到 `ssh-agent`: ```bash eval "$(ssh-agent -s)" ssh-add ~/.ssh/id_rsa ``` - 确保 `~/.ssh/config` 文件中配置了正确的 Host 和 IdentityFile: ```bash Host your-git-server HostName your-git-server User git IdentityFile ~/.ssh/id_rsa PreferredAuthentications publickey ``` - 测试 SSH 连接是否正常: ```bash ssh -vT git@your-git-server ``` 查看输出中是否成功认证并加载了密钥[^1]。 ### 3. 使用 HTTPS 替代 SSH 如果 SSH 配置复杂或权限受限,可以尝试将远程仓库地址改为 HTTPS 协议: ```bash git clone https://your-git-server/your-repo.git ``` 这将绕过 SSH 子系统的问题,但需要输入用户名和密码(或使用凭据管理器保存凭证)。 ### 4. 权限和路径问题 在某些情况下,远程服务器上的 Git 可执行文件路径未被正确识别,或者用户权限不足。 **解决方案:** - 确保远程服务器上 Git安装且路径正确: ```bash which git ``` 应返回 `/usr/bin/git` 或类似路径。 - 确保远程用户有权限访问仓库目录,并且 Git 服务(如 Gitolite、GitLab Shell)配置正确。 ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值