GitHub and Bitbucket accounts in a same PC.

J. Sebastian Ricarde
avocoders
Published in
2 min readNov 29, 2017

Sometimes, we change jobs and the company uses bitbucket, but you have your personal account on github, at that moment the problem arises “how to setup multiple accounts (GitHub, Bitbucket) on the same PC”, in the following steps I will explain how to solve it:

1. Generate different ssh public keys.

We need to be careful with this step because if you have another old ssh public key you could replace it, for that reason I recommend don’t name the rsa keys with the default name “id_rsa”:

2. Attach each key to their corresponding account

Attach in GitHub account:

Copy on the clipboard the content of your “id_rsa_github.pub” file with the command clip:

Login in your GitHub account and continue with the following list of steps:

  1. In the upper-right corner of any page, click your profile photo, then click Settings.
  2. In the user settings sidebar, click SSH and GPG keys.
  3. Click New SSH key or Add SSH key.
  4. In the “Title” field, add a descriptive label for the new key. For example, if you’re using a personal PC, you might call this key “Personal PC”.
  5. Paste your key into the “Key” field.
  6. Click Add SSH key.

Attach in Bitbucket account:

Copy on the clipboard the content of your “id_rsa_bitbucket.pub” file with the command clip:

Login in your Bitbucket account and continue with the following list of steps:

  1. Choose Bitbucket settings from your avatar in the lower left, the Account settings page opens
  2. Click SSH keys.
  3. Click Add key.
  4. Enter a Label for your new key, for example, “Work PC”.
  5. Paste the copied public key into the SSH Key field.
  6. Click Save.

3. Create the config file.

Create a config file in ~/.ssh/ with the command touch:

Edit the config file with your text editor or use vim “vim config”:

4. Update stored ssh keys.

Clear currently stored ssh keys:

Add ssh keys:

Test that GitHub validates the ssh key:

Test that Bitbucket validates the ssh key:

5. And try-out.

On Github, create a new repo, called project-personal, back on your local and create a directory:

Note: In the above code, I used the host for personal GitHub account git@gh instead of git@github.

Repeat the proccess for work bitbucket account, Create a repo on Bitbucket called project-work, and create a local directory:

Thanks for reading.

--

--