2017-07-13 42 views
0

我有兩個Bitbucket帳戶。一個是辦公室,另一個是個人。現在,我還爲這些帳戶創建了兩個SSH密鑰並添加了密鑰,但現在似乎無法訪問我的個人帳戶。Bitbucket訪問錯誤與兩個不同的Bitbucket帳戶

當我嘗試git push -u origin develop,我得到這個錯誤:

repository access denied. 
fatal: Could not read from remote repository. 

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

這是我.ssh/config文件:

1 Host bitbucket.org 
2  User git 
3  Hostname bitbucket.org 
4  IdentityFile ~/.ssh/id_rsa_bitbucket 
5  TCPKeepAlive yes 
6  IdentitiesOnly yes 
7 
8 Host bitbucket.org 
9  User git 
10  Hostname bitbucket.org 
11  IdentityFile ~/.ssh/id_rsa 
12  TCPKeepAlive yes 
13  IdentitiesOnly yes 

第一個是我的辦公室和2一個是我的個人帳戶。任何想法我怎麼能解決這個問題?

回答

0

你必須以不同的方式爲它們命名:

Host bitbucket1 
    User git 
    Hostname bitbucket.org 
    IdentityFile ~/.ssh/id_rsa_bitbucket 
    TCPKeepAlive yes 
    IdentitiesOnly yes 

Host bitbucket2 
    User git 
    Hostname bitbucket.org 
    IdentityFile ~/.ssh/id_rsa 
    TCPKeepAlive yes 
    IdentitiesOnly yes 

而在你的Git倉庫使用bitbucket1bitbucket2代替bitbucket.org

+0

不幸的是,這並沒有工作:(但我使用不同的方法工作,我會在另一個答案解釋。 –

0

很可能與我的兩個ssh密鑰有一些衝突,我的私人帳戶無法從本機獲得任何許可給我的Bitbucket。

於是我突然想到要我的辦公室ID從

Settings > User and Group Access > User 

分配給我個人的回購並給予ID管理權限,它完美地工作。

也許這不是優雅的方式,而不是問題的實際解決方案,但它在此刻完美運作。

0

Bitbucket允許SSH訪問回購站的「git」或「hg」以外的用戶名。您可以在工作相關的回購站上執行類似git remote set-url origin [email protected]:owner/repo.git的操作(假設「myawesomeusername」是您的用戶名,「owner/repo.git」是所討論回購的路徑),或者您可以編輯每個中的.git/config文件回購將URL中的[email protected]更改爲[email protected]