Skip to content

Instantly share code, notes, and snippets.

@andriesfc
Forked from mjrulesamrat/multiple_ssh_keys.md
Created March 5, 2024 19:04
Show Gist options
  • Save andriesfc/199b62974eb726ecd6e0726b7eb59364 to your computer and use it in GitHub Desktop.
Save andriesfc/199b62974eb726ecd6e0726b7eb59364 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment