【发布时间】:2014-12-16 00:22:36
【问题描述】:
我正在尝试在 CentOS VPS 上将私人存储库从 Bitbucket 克隆到 /var/www。
我在 VPS 上生成了一个 SSH 密钥对,并将 .pub 文件作为(只读)部署密钥上传到 Bitbucket。
密钥设置正确,因为当我连接时使用:
ssh -T git@bitbucket.org
效果很好:
authenticated via deploy key.
You can use git or hg to connect to Bitbucket. Shell access is disabled.
This deploy key has read access to the following repositories:
<username>/<repo_name>: <Deployment Key Nickname> -- <vps_username>@<vps_hostname>
Connection to bitbucket.org closed.
到目前为止,一切都很好。但是当我尝试将 repo 克隆到 /var/www 时,我得到:
fatal: could not create work tree dir '<repo_name>'.: Permission denied
当我 sudo 时,我得到了
Permission denied (publickey).
我在Bitbucket docs 中找到了有关上述错误的注释:
您在尝试连接时使用了 sudo 使用 Bitbucket 克隆存储库或任何其他 SSH 操作时,您不需要使用 sudo。
看起来我需要以 root 权限运行才能创建树,但如果我这样做了,它就没有正确使用 SSH 密钥。
所以,我对 /var/www 目录进行了 chmod,以便我的非 root 用户拥有写入权限,并且一切正常。但是该目录现在是 777 (drwxrwxrwx),这可能不太好。
有没有更好的方法来处理这个问题?我想让 /var/www 回到 755,但我不想每次更新代码时都使用临时 chmod...
提前致谢!
【问题讨论】:
标签: git bitbucket file-permissions centos6.5