2017-07-24 39 views
1

我有2個bitbucket的帳戶 - 一個用於工作,一個用於個人。在一臺筆記本電腦上配置2個Bitbucket帳戶:無法克隆代碼

Defaultly我使用的是工作帳戶,但現在需要克隆從人帳戶下的存儲庫的一些代碼,並得到這個錯誤:

git clone [email protected]:my_personal/project.git 
Cloning into 'project'... 
repository access denied. 
fatal: Could not read from remote repository. 

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

我產生新的一套鑰匙在我的筆記本電腦爲個人Bitbucket帳戶 - personalpersonal.pub。我將這個personal密鑰添加到個人BB賬戶的SSH賬戶設置。

然後,我已經設置了/Users/adam/.ssh/config文件:

# Work account 
Host bitbucket.org 
    HostName bitbucket.org 
    User my_working_bb_id 
    PreferredAuthentications publickey 
    IdentityFile ~/.ssh/id_rsa 

# Personal account 
Host bitbucket.org_personal 
    HostName bitbucket.org 
    User personal_bb_id 
    PreferredAuthentications publickey 
    IdentityFile ~/.ssh/personal 

我也跑ssh-add -l

2048 SHA256:bYwG+K01In4aDtux36u58ywVqhmALTandY4h8yEg7YE /Users/adam/.ssh/id_rsa (RSA) # <- work-account 
2048 SHA256:I3FFdzuS1a3oVy2LAgE+Uh3iQfDIYwys24ZMAAwT0B0 /Users/adam/.ssh/[email protected] (RSA) 
2048 SHA256:ye3efWFfSt5tOqj7+APV9eU/Q7lquvbJc0GywyuGm68 /Users/adam/.ssh/presonal (RSA) 
2048 SHA256:aGsdBd6lqTqRBXuusvblyUbM9d7Hc5+oJNdVgUwumIM /Users/adam/.ssh/presonal (RSA) 

當我運行ssh -T [email protected],我得到:

logged in as my_work_bb_id.

我懷疑這裏(上面)可能是問題?在我的筆記本電腦上,我仍然只能使用我的工作 - BB ID登錄?

或問題在哪裏?我整個下午都在與這個問題鬥爭,但無法繼續前進。

我會感激每一個建議!

回答

1

如果在〜/ .ssh/config文件中有兩個單獨的條目,那麼您應該可以使用git clone bitbucket.org_personal:owner/repo.git作爲您的個人用戶進行克隆。你也應該能夠用你自己的用戶名,而不是「git」或「hg」(類似於git clone [email protected]:owner/repo.git)來克隆,推送和拉取。

0

如果你有更多的密鑰,你應該在你的配置文件中使用IdentitiesOnly yes。它將避免使用默認密鑰,它將使用配置文件中提供的密鑰作爲優先級。

當然,你需要克隆的方式在其他的答案中描述:使用主機別名從您的ssh配置:

git clone [email protected]_personal:my_personal/project.git 
相關問題