2016-03-02 35 views
0

因爲我希望能夠使用push代碼使用多個身份/密鑰。要做到這一點我在01​​定義一些別名:如何使用別名訪問遠程存儲庫?

#github.com default 
Host github.com 
    HostName github.com 
    User git 
    IdentityFile ~/.ssh/id_rsa_foo 

#github.com-foo 
Host github.com-foo 
    HostName github.com 
    User git 
    IdentityFile ~/.ssh/id_rsa_foo 

#github.com-bar 
Host github.com-bar 
    HostName github.com 
    User git 
    IdentityFile ~/.ssh/id_rsa_bar 

... 

要訪問我的回購我用那麼別名,例如:

$ git remote add origin [email protected]:MyOrganizationOrPersonalAccount/MyRepo.git 
$ git remote -v 
origin [email protected]:MyOrganizationOrPersonalAccount/MyRepo.git (fetch) 
origin [email protected]:MyOrganizationOrPersonalAccount/MyRepo.git (push) 

這已經可以正常使用了很長一段時間。而現在(可能是因爲我重新安裝了OS)沒有關係的工作了:

$ git fetch 
Unable to open connection: 
Host does not existfatal: Could not read from remote repository. 

Please make sure you have the correct access rights 
and the repository exists. 

什麼可能導致此問題,以及如何獲得遠程訪問工作?

UPDATE

我重新安裝的Git是舒爾,我使用OpenSSH客戶端。現在它可以工作。所以我想這個問題是由於使用plink作爲SSH客戶端引起的,並不考慮~/.ssh/config的設置。

+0

你的鑰匙變得無效?你有沒有嘗試添加新的密鑰? – TheGeorgeous

+0

@TheGeorgeous哦,對不起,只是忘了發佈CLI輸出。更新了問題。 – automatix

+0

你有沒有用別名試過這個'ssh -T git @ github.com'? – TheGeorgeous

回答

0

我前一段時間得到這個錯誤,要解決它,我取出遙控器的形式列表

git remote remove MyRemote 

然後再次添加它,使用HTTP鏈接,而不是如果SSH密鑰

git remote add Http://URLToRepositoryHere 
+0

我不需要HTTP鏈接,我想能夠'commmit'。 – automatix

+0

我遇到了同樣的問題,當我通過HTTP協議添加遠程時,我的問題得到了解決。我使用Bitbucket作爲一個遠程,看起來他們不喜歡你使用ssh。所以在我切換到HTTP之後,它們都運行良好,我可以毫無問題地推動和拉動。 –