情况:Debian12 主机,apache2 httpd 为 git CGI 提供服务(位于/repos/git
)以克隆存储库。存储库存储在/repos
目录中,并归用户所有,git
以便用户能够通过 ssh 访问它们(例如,能够在控制台中写入)。git push [email protected]:repos/repo.git
问题是,git clone https://example.com/repos.git
当所有内容都归 git 用户所有时,运行时 git CGI 会将其打印到stderr
:
(13)Permission denied: [client <ip>:<port>] AH00035: access to /repos.git/info/refs denied (filesystem path '/repos/git') because search permissions are missing on a component of the path
如果我运行,克隆命令可以正常工作chown -R www-data:www-data /repos
。但是这样,我无法通过 ssh 访问 repo(fatal: detected dubious ownership in repository at /repos/repo.git
在客户端,即使git
用户在www-data
组内)
我尝试将目录设为用户git
和组所拥有www-data
并sharedRepository=0640
在配置中启用(我也尝试了不同的值),但 CGI 脚本失败并出现此dubious ownership
错误。我尝试设置全局配置,尝试创建目录2777
和0666
权限,但都不起作用。
澄清一下,我真的不喜欢以www-data
用户身份登录以 ssh 访问 git repos。我觉得一定有sharedRepository
我可以做的事情,但我不知道应该怎么做。
gitweb
附言:由于我正在运行,所以不需要cgit
,并且apache2
配置(至少在理论上)在这里应该无关紧要。