2011-11-16 56 views
3

我用這臺計算機上以前的github帳戶guthub設置叫我的帳戶當我運行此命令Github上錯誤的用戶名

ssh -T [email protected] 
Hi myaccount! You've successfully authenticated, but GitHub does not provide shell access. 

好,不過我現在設置有一個名爲samaccount新GitHub的帳戶,但我不能運行這個命令我得到這個錯誤。

git push -u origin master 

我得到這個錯誤

ERROR: Permission to samueleast/Samuel-East-S3-Audio-Playlist-Player.git denied to myaccount. 

我不希望它使用我的帳戶應該使用samaccount!

我按照這裏的所有步驟http://help.github.com/mac-set-up-git/ 設置全新的ssh密鑰。

,並運行此命令多次

git config --global user.name "samaccount" 

,但它仍然使用我的帳戶及其SOOO煩人我要去哪裏錯了???

+0

所以你創建了兩個github上帳戶在同一臺​​計算機上?你上傳了相同的密鑰嗎?我的意思是'id_rsa.pub' –

回答

12

GitHub將您識別爲myaccount,因爲SSH使用的密鑰對應於已添加到GitHub網站上myaccount帳戶的公鑰。

如果你想完全切換到使用sameueleast帳戶,而不是myaccount,你可以做到以下幾點:

  • 登錄到GitHub的網站爲myaccount
  • 進入「帳戶設置」
  • 圍棋到「SSH公鑰」
  • 從該列表中刪除您的公鑰
  • 註銷
  • 登錄到GitHub的網站爲samueleast
  • 進入「帳戶設置」 - >「SSH公鑰」
  • 選擇「添加其他公共密鑰」,並在你的公鑰的內容粘貼。您的公鑰將(可能)被稱爲id_rsa.pubid_dsa.pub,並且位於您的.ssh目錄中。

在另一方面,如果你希望能夠爲使用myaccountsamueleast推到GitHub上的時候,你就需要在~/.ssh/config創建[email protected]別名,如:

Host github-myaccount 
    User git 
    Hostname github.com 
    PreferredAuthentications publickey 
    IdentityFile ~/.ssh/id_dsa-myaccount.pub 

Host github-samueleast 
    User git 
    Hostname github.com 
    PreferredAuthentications publickey 
    IdentityFile ~/.ssh/id_dsa-samueleast.pub 

那假定你已經生成了第二個SSH密鑰對,並給出了他們的名字,如上所述。然後你需要確保你在你的git遙控器的URL中使用了適當的別名。例如,如果你想改變你的origin好遙控器,推到原點的意思是「推到起源samueleast」,你可以這樣做:

git remote set-url origin \ 
    [email protected]:samueleast/Samuel-East-S3-Audio-Playlist-Player.git 
+0

謝謝你的回答,我現在就試試這個。 – DCHP

+0

感謝第一次工作排序;) – DCHP

+0

地獄是!英雄! – Manu