简体   繁体   English

如何设置 ssh 访问权限以远程管理裸存储库?

[英]how can I set up ssh acces to remte bare repository for admin?

On a VPS I can login using在 VPS 上,我可以使用登录

ssh admin@server.com

I have created a bare repository in:我在以下位置创建了一个裸存储库:

/var/repo/site.git

which has:其中有:

drwxr-xr-x   7 root root  119 Jan 31 13:35 site.git

Locally I set up:我在本地设置:

git remote add production ssh://admin@server.com/../../var/repo/site.git git 远程添加生产 ssh://admin@server.com/../../var/repo/site.git

But when I try tyo push I get this error:但是当我尝试 tyo push 我得到这个错误:

PS D:\path\site-directory> git push production master
admin@server.com's password: 
Enumerating objects: 1152, done.
Counting objects: 100% (1152/1152), done.
Delta compression using up to 8 threads
Compressing objects: 100% (1073/1073), done.
remote: fatal: Unable to create temporary file '/var/repo/site.git/./objects/pack/tmp_pack_XXXXXX': Permission denied
fatal: sha1 file '<stdout>' write error: Broken pipe
error: remote unpack failed: index-pack abnormal exit
To ssh://server.com/../../var/repo/site.git
 ! [remote rejected] master -> master (unpacker error)
error: failed to push some refs to 'ssh://server.com/../../var/repo/site.git'

I think that I have to adjust some permissions, or I may have set up the wrong path.我认为我必须调整一些权限,否则我可能设置了错误的路径。

Can anyone help me figure out how to troubleshoot?谁能帮我弄清楚如何排除故障?

This directory:这个目录:

drwxr-xr-x   7 root root  119 Jan 31 13:35 site.git

Has a user ownership set to root.将用户所有权设置为 root。 Since admin is not the owner of the directory, Linux next checks if the directory is world-writable, which it is not, so it denies access.由于 admin 不是目录的所有者,Linux 接下来检查目录是否是全局可写的,它不是,所以它拒绝访问。

The simplest way to solve this is to make admin the owner of this directory.解决这个问题的最简单方法是让 admin 成为该目录的所有者。

Run this command:运行此命令:

sudo chown -R admin:admin /var/repo/site.git

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM