2014-04-19 34 views
1

我在遠程機器上設置了gitolite並從本地配置它。我不想讓我的活動顯示爲「管理員」,並創建用戶和密鑰「諾亞」。創建「諾亞」回購後,我被拒絕訪問。我相信因爲我仍然是「管理員」。在一臺機器上的多個gitolite用戶

所以我在一臺機器上有兩個帳戶。我該如何切換?

感謝

UPDATE:

這是我本地的〜/ .ssh /配置/:

​​

本地命令:遠程 git clone [email protected]:reponame

的authorized_keys: command="/usr/share/gitolite/gl-auth-command noah",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty ssh-rsa ...

重要的是,我在Mac上。我也做ssh-add -K ~/.ssh/noah

更新2:

這裏是auth.log:

server sshd[2834]: Invalid user git-noah from localip 
server sshd[2834]: input_userauth_request: invalid user git-noah [preauth] 

這裏的本地權限:

drwx------+ 13 noah 442 19 Apr 14:47 .ssh 

遠程權限:

-rwx------ 1 git 1067 Apr 19 14:57 authorized_keys 
drw------- 2 git 4096 Apr 19 14:57 .ssh 
+0

然後你需要調試SSH部分,而不是gitolite部分:http://stackoverflow.com/a/23054951/6309和http://stackoverflow.com/a/7443893/6309 – VonC

+0

我剛剛意識到這個問題! (或至少其中一個問題)您正在使用git-noah @ remote-ip:reponame。那是錯的。正如我在我的回答中所提到的,你必須使用'git-noah:reponame'。注意':'。這將照顧'無效的用戶git-noah'錯誤消息。 – VonC

+0

@VonC這擺脫了那個錯誤,但密碼仍然提示。 – Noah

回答

1

如果您正在使用具有不同ssh密鑰的拖拽帳戶(如「How do programs like gitolite work?」中所述),則您切換的方式是使用指示ssh查找noah密鑰(而不是管理員密鑰)的ssh url。

對於這一點,你需要一個SSH的配置文件(在你的HOME/.ssh/config),正如我在「How to use specified key when working with github via portablegit?」詳細介紹:

#admin account 
Host gitolite-admin 
    HostName yourGitoliteServer 
    User git 
    IdentityFile ~/.ssh/id_rsa_admin 

#noah account 
Host gitolite-noah 
    HostName yourGitoliteServer 
    User git 
    IdentityFile ~/.ssh/id_rsa_noah 

克隆你的諾亞做回購,你會使用哪個引用的URL右鍵入口在ssh配置文件中。

git clone gitolite-noah:yourRepo.git 

通過使用URL,您要設置遠程命名origin:你可以用git remote -v看到它。

這意味着任何使用該遠程名稱(如git pull origin或git push origin)的命令都將使用該ssh url,它明確指向一個特定的私有ssh密鑰,該密鑰又將您標識爲。


調試ssh最有效的方法是檢查sshd如何監聽服務器上的查詢。

既然是一個Debian(as per out discussion):

  • /usr/sbin/sshd -d -D -p 222在服務器上,
  • ssh -p 222 -Tv git-noah客戶

上(注意使用專用端口的伎倆,這樣一來,沒有必要停止實際的sshd:它是一個特殊端口上的一次性會話,僅用於調試目的)

我們很快看到

Could not open authorized keys '/home/git/.ssh/authorized_keys': Permission denied 

這與一致:

[email protected]:/# ls -lato ~git/ 
drw------- 2 git 4096 Apr 19 14:57 .ssh 

一個chmod 700 ~git/.ssh固定的情況。

+0

推送和提交等命令如何?每次都必須指定用戶和回購嗎?有沒有辦法選擇默認? – Noah

+1

@Noah看到我編輯的答案:該URL足以識別你到Gitolite。 – VonC

+0

我正在做'git clone git-noah @ remotip:repo'。它要求輸入密碼。 Server auth.log表示'sshd [3283]:input_userauth_request:invalid user git-noah [preauth]'。 – Noah

相關問題