2014-10-20 72 views
0

我試圖在CentOS VPS上從Bitbucket克隆到/ var/www的私人回購。/var/www的適當權限

我在VPS上生成了SSH密鑰對,並將.pub文件作爲(只讀)部署密鑰上傳到Bitbucket。

的關鍵是正確安裝,因爲當我連接使用:

ssh -T [email protected] 

正常工作:

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. 

到目前爲止,一切都很好。但是,當我嘗試克隆一個回購到在/ var/WWW,我得到:

fatal: could not create work tree dir '<repo_name>'.: Permission denied 

當我sudo的話,我得到

Permission denied (publickey). 

我發現這個便條在Bitbucket docs關於所述錯誤:

You used sudo when attempting the connection You do not need to use sudo when cloning a repository or any other SSH action with Bitbucket.

它看起來像我需要以root權限運行創建樹,但如果我這樣做,它不正確使用SSH密鑰。

因此,我chmod'd/var/www目錄,以便我的非root用戶將有寫權限,並且一切工作正常。但那個目錄現在是777(drwxrwxrwx),可能並不好。

有沒有更好的方法來處理這個問題?我想要/ var/www回到755,但是我不想每當我想更新我的代碼時都臨時使用chmod ...

在此先感謝!

回答

2

使/ var/www組可寫(chmod g+w /var/www)並將其組更改爲可信用戶(包括您)所屬的組。如果你不想打開所有的/ var/www,那麼也許你可以引入一個額外的級別,比如/ var/www/foo,你打開它。