23 เมษายน 2560

Manage multiple bitbucket accounts

steps to manage multiple bitbucket accounts

1. create a new ssh key for the 2nd account
ssh-keygen -f ~/.ssh/<new ssh key name-C "<your email>"
e.g. if i want to create key name "test", and my email is "test@gmail.com",
i will run the command > ssh-keygen -f ~/.ssh/test -C "test@gmail.com"
then you will get 2 new files, test & test.pub


2. add new key to the key manager
ssh-add ~/.ssh/<new ssh key name>
e.g. ssh-add ~/.ssh/test


3. copy ~/.ssh/<new ssh key name>.pub to bitbucket

- goto bitbucket.org and log-in

- goto "bitbucket settings" menu

- at the "security" menu, click "SSH keys"

- click "Add key"

- copy ~/.ssh/<new ssh key name>.pub

- paste your key


4. modify ~/.ssh/config like this

Host bitbucket.org
  Hostname bitbucket.org 
  IdentityFile ~/.ssh/id_rsa 

Host bitbucket-personal
  Hostname bitbucket.org 
  IdentityFile ~/.ssh/test

* i create the new host "bitbucket-personal" for my 2nd key, and set identityFile to my new key also


5. then you can clone your repository like this

git clone git@bitbucket-test:/.git

e.g. git clone git@bitbucket-personal:test/my-repo.git

บทความยอดนิยม (ล่าสุด)

บทความยอดนิยม (1 ปีย้อนหลัง)