links: Software Installation MOC


Setup Multiple ssh keys

Generating ssh keys 1

In order to generate ssh key use the following command

ssh-keygen -t ed25519 -C "your_email@example.com"

Choose apt file names and save to ~/.ssh folder

For example:

  • bitbucket personal: id_bb_personal
  • bitbucket work: id_bb_work
  • github personal: id_gh_personal
  • github work: id_gh_work

Add ssh keys to ssh-agent

  1. Start ssh agent in background
eval "$(ssh-agent -s)"
  1. create a config file if it doesn’t exist
touch ~/.ssh/config
  1. Open config file and add your identities
Host github.com
  HostName github.com
  IdentityFile ~/.ssh/id_rsa_github

Host gitlab.com
  HostName gitlab.com
  IdentityFile ~/.ssh/id_rsa_gitlab

Host bitbucket.org
  HostName bitbucket.org
  IdentityFile ~/.ssh/id_rsa_bitbucket


Host companyname.github.com
  HostName github.com
  IdentityFile ~/.ssh/id_rsa_github_companyName

Host companyname.gitlab.com
  HostName gitlab.com
  IdentityFile ~/.ssh/id_rsa_gitlab_companyName

Host companyname.bitbucket.org
  HostName bitbucket.org
  IdentityFile ~/.ssh/id_rsa_bitbucket_companyName
  1. copy the public keys and paste them in respective github, bitbucket accounts

Finally to clone repos

Personal repos doesn’t needs to be added anything

For professional repos, you need to add the Host (companyname.github.com)

git clone git@companyname.bitbucket.org:companyName/company-project.git

tags: git , setup

source:

Footnotes

  1. ssh key generation instructions from github