links: [[Software Installation MOC]] --- # Setup Multiple ssh keys ## Generating ssh keys [^1] In order to generate ssh key use the following command ```shell ssh-keygen -t ed25519 -C "[email protected]" ``` 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 ```shell eval "$(ssh-agent -s)" ``` 2. create a config file if it doesn't exist ```shell touch ~/.ssh/config ``` 3. 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 ``` 4. 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) ```shell git clone [email protected]:companyName/company-project.git ``` --- tags: #git , #setup source: - [Multiple ssh keys setup](https://dev.to/shostarsson/how-to-setup-multiple-ssh-keys-for-multiple-github-bitbucket-accounts-2ji0) [^1]: [ssh key generation instructions from github](https://docs.github.com/en/github/authenticating-to-github/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent)