2011-06-21 18 views
1

我有一種情況下,對於大小的限制,我不能作爲一個特定的網站在同一臺服務器上的裸倉庫。所以我已經在服務器A上建立了一個裸倉庫,我希望在推動主分支的時候也很高興。 在掛鉤/更新後,它應該ssh到活服務器並拉動主分支。更新後的ssh遠程現場服務器和拉主分支問題

我在現場服務器上生成了一個公共ssh密鑰,授權它並將公鑰複製到裸露的repo服務器上的/var/www/.ssh/authorized_keys文件中。 Bascially做了這個網站上的所有內容here

但是它試圖驗證到活服務器時失敗。

更新之後看起來是這樣的:

ssh [email protected] 

cd cd/path/to/site/.git || exit 
git pull bare master 
exit 

我得到這個消息

$ git push server master 
[email protected]'s password: 
Counting objects: 5, done. 
Delta compression using up to 3 threads. 
Compressing objects: 100% (3/3), done. 
Writing objects: 100% (3/3), 279 bytes, done. 
Total 3 (delta 2), reused 0 (delta 0) 
remote: 
remote: *** Pulling changes into Live [Live's post-update hook] *** 
remote: 
remote: Permission denied, please try again. 
remote: Permission denied, please try again. 
remote: Permission denied (publickey,gssapi-with-mic,password). 
remote: fatal: The remote end hung up unexpectedly 
To ssh://[email protected]/var/git/websiteToUpdate.git 
    b251909..883d129 master -> master 
+0

您將「活」和「A」服務器混淆了一下。你也不會在任何地方以'www'用戶身份登錄,所以你爲什麼提到'/ var/www/.ssh/authorized_keys'(存儲任何與ssh相關的文件根目錄可能是個壞主意)。 –

回答

0

你似乎對live,這意味着live將ssh登錄回到www.ServerAAddress.com運行git pull。因此,有2茶匙需要使用密碼,更少的公共密鑰進行驗證,其中一人是不正確的授權:從「A」(「裸」),以「活」

  1. SSH需要私有密鑰(.ssh/id* )存儲在「現場」的「A」和公鑰上(在.ssh/authorized_keys)。
  2. ssh從「live」返回到「A」(在git pull之內)需要存儲在「live」上的私鑰和「A」上的公鑰。鑰匙應該是不同的。

服務器上的位置可能不同。 「A」上的文件需要在userForBare的家中,而「live」上的文件需要在www用戶的家中。

看在日誌(SSH通常登錄到/var/log/auth/var/log/security),並檢查它實際上找到它應該,它是願意看它的公共密鑰:

  • 許多菜單將已將/var/www設爲$HOMEwww用戶,因此您可能需要將.ssh/authorized_keys放在其他地方。
  • ssh拒絕讀取任何內容$HOME/.ssh/如果文件或任何根目錄以外的任何目錄都可以被除該用戶或根以外的任何人寫入,則例如/var/www是可分組的,ssh會拒絕/var/www/.ssh/authorized_keys,可能會受到影響。
相關問題