2014-03-03 50 views
1

我有ec2服務器與Ubuntu 12.04,我已經添加了一個更多的用戶「git」到服務器。生成ssh密鑰並上傳到兩個用戶.ssh目錄。所以,現在我可以訪問我的服務器git推ssh到服務器,公鑰錯誤

ssh [email protected] 
ssh [email protected] 

我創建了一個純倉庫到/opt/git/gitpg.git,並將此作爲遙控器來我的本地庫

sudo git remote add deploy [email protected]:/opt/git/gitpg.git 

當我試圖把這個倉庫,它顯示認證錯誤。我也試過this solution,但它也行不通。

任何人都可以請建議什麼可能是可能的原因?

更新

,當我試圖git push deploy master而不是sudo git push deploy master它成功連接,但無法由於權限推。

Counting objects: 5, done. 
Delta compression using up to 4 threads. 
Compressing objects: 100% (3/3), done. 
Writing objects: 100% (3/3), 356 bytes, done. 
Total 3 (delta 1), reused 0 (delta 0) 
To [email protected]:/opt/git/gitpg.git 
    d6cc9c3..25ddaa4 master -> master 
error: unable to create directory for .git/refs/remotes/deploy/master 
error: Cannot lock the ref 'refs/remotes/deploy/master'. 

更新2

我改變本地目錄權限設置爲當前用戶,現在它的工作沒有sudo。 但我仍然不知道爲什麼它也沒有與sudo一起工作。

+0

你確定你已經把你在你的git的服務器生成正確的公鑰? – Agis

+0

我可以在不定義pem文件的情況下登錄,如ssh [email protected] – Hemc

+0

當您通過ssh登錄時,是否可以在服務器中創建目錄? – Banago

回答

0

嘗試把你的公鑰在服務器.ssh/authorized_keys或使用另一個這樣的協議:

ssh://[email protected]/opt/git/gitpg.git 
+0

謝謝@Banago,當我使用SSH://它說ssh:'無法解析主機名example.com ::名稱或服務未知' – Hemc

+0

我的公衆已存在於服務器authorized_keys – Hemc

+0

是的,我已經把一個額外的冒號這個例子。只有在指定端口時才需要它。 – Banago