Skip to content

Instantly share code, notes, and snippets.

@mjrulesamrat
Last active June 11, 2024 21:09
Show Gist options
  • Save mjrulesamrat/d054630303563a3a286c3f996b9f132f to your computer and use it in GitHub Desktop.
Save mjrulesamrat/d054630303563a3a286c3f996b9f132f to your computer and use it in GitHub Desktop.
How to Setup Multiple Ssh Keys for Multiple Github/Bitbucket accounts

How to Setup Multiple Ssh Keys for Multiple Github/Bitbucket accounts

create the SSH keys.

ssh-keygen -t rsa -b 4096 -C "mjrulesamrat@gmail.com"

Add the SSH Keys to the SSH-Agent

ssh-add id_rsa_mjrulesamrat

Configuration

Create config file and add multiple hosts to accomodate different accounts of github, bitbucket or gitlab.

vim ~/.ssh/config
Host github.com
  HostName github.com
  IdentityFile ~/.ssh/id_rsa

Host mjrulesamrat.github.com
  HostName github.com
  IdentityFile ~/.ssh/id_rsa_mjrulesamrat

Other examples of different accounts:

  • mjrulesamrat.gitlab.com

  • mjrulesamrat.bitbucket.org

Add the Keys to your Repositories Accounts

Add id_rsa_mjrulesamrat.pub to github account ssh keys

cat ~/.ssh/id_rsa_mjrulesamrat.pub

Clone repo and start working..

git clone git@mjrulesamrat.github.com:mjrulesamrat/docker-commands.git
@medichops1
Copy link

The instructions on the bitbucket article didnt help me either.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment