问题
When using SmartGit as SSH-client, it caches the first selected key. And when further you trying to pull/push to another repo, SmartGit says "Access denied".
SmartGit saves to preferences what key should it use to connect to the Bitbucket. But all repos has address: ssh://git@bitbucket.org in SmartGit preferences.
回答1:
As mentioned here and in this thread, you should be able to reference multiple private ssh keys in a %HOME%\.ssh\config file, changing the url to bitbucket1:userA/myrepo1, bitbucket2:userA/myrepo2.
That means that:
- you have selected System SSH in the preferences
- have added a
%HOME%\.ssh\config filewith:
config:
host bitbucket1
user git
hostname bitbucket.org
port 22
identityfile /C/path/to/.ssh/key1
host bitbucket2
user git
hostname bitbucket.org
port 22
identityfile /C/path/to/.ssh/key2
- in
/C/path/to/.ssh/, you have akey1(private) andkey1.pub(public) ssh files (same forkey2/key2.pub)
来源:https://stackoverflow.com/questions/32324376/how-to-use-different-keys-for-different-bitbucket-repos-in-smartgit