Working with multiple GIT accounts

If You need to authenticate on GIT server with multiple SSH keys You can simplify this with GIT configuration. Create new id_rsa key files:

ssh-keygen -f ~/.ssh/id_rsa_demo_one
ssh-keygen -f ~/.ssh/id_rsa_demo_two

Then setup those files in ~/.ssh/config file:

Host demo_one.bitbucket.org
  HostName bitbucket.org
  User YOUR_BITBUCKET_USER_2
  IdentityFile ~/.ssh/id_rsa_demo_one
  IdentitiesOnly yes
Host demo_two.bitbucket.org
  HostName bitbucket.org
  User YOUR_BITBUCKET_USER_2
  IdentityFile ~/.ssh/id_rsa_demo_two
  IdentitiesOnly yes

Now when You want to clone from repository bitbucket.org/example/example You need to specify host in clone command:

git clone git@demo_one.bitbucket.org.org:example/example.git

or

git clone git@demo_two.bitbucket.org.org:example/example.git

Same trick works with any GIT server.

Enjoy 馃檪

Praca z wieloma kontami GIT

Je偶eli musisz uwierzytelni膰 si臋 na serwerze GIT za pomoc膮 wielu kluczy SSH, mo偶esz to upro艣ci膰 dzi臋ki prostej konfiguracji GIT. Utw贸rz nowe pliki kluczy id_rsa:

ssh-keygen -f ~/.ssh/id_rsa_demo_one
ssh-keygen -f ~/.ssh/id_rsa_demo_two

Nast臋pnie ustaw te pliki w pliku ~/.ssh/config:

Host demo_one.bitbucket.org
  HostName bitbucket.org
  User YOUR_BITBUCKET_USER_2
  IdentityFile ~/.ssh/id_rsa_demo_one
  IdentitiesOnly yes
Host demo_two.bitbucket.org
  HostName bitbucket.org
  User YOUR_BITBUCKET_USER_2
  IdentityFile ~/.ssh/id_rsa_demo_two
  IdentitiesOnly yes

Teraz, gdy chcesz sklonowa膰 z repozytorium bitbucket.org/example/example, musisz okre艣li膰 hosta w poleceniu clone:

git clone git@demo_one.bitbucket.org.org:example/example.git

lub

git clone git@demo_two.bitbucket.org.org:example/example.git

Ta sama sztuczka dzia艂a z ka偶dym serwerem GIT.

Powodzenia 馃檪