Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Multiple SSH keys GitHub setup

Multiple SSH Keys settings for different github account

create different public key

Make sure you have .ssh folder created:

$ mkdir ~/.ssh
$ chmod 700 ~/.ssh

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "" -f "key-name"

Please refer to github ssh issues for common problems.

for example, 2 keys created at:


then, add these two keys as following

Make sure that the ssh-agent is running:

eval `ssh-agent`
$ ssh-add ~/.ssh/id_rsa_github
$ ssh-add ~/.ssh/id_rsa_bitbucket

you can delete all cached keys before

$ ssh-add -D

finally, you can check your saved keys

$ ssh-add -l

Modify the ssh config

$ cd ~/.ssh/
$ touch config
$ subl -a config

Then added

# GitHub account
	User git
	IdentityFile ~/.ssh/id_rsa_github

# Bitbucket account
	User git
	IdentityFile ~/.ssh/id_rsa_bitbucket

Setup the SSH in the service of your choice:

After that, check if everything is ok:

  • GitHub: ssh -T
  • Bitbuket: ssh -T

Clone you repo and modify your Git config

clone your repo git clone project

cd project and modify git config

$ git config "foo"
$ git config "" 

or you can have global git config $ git config --global "foo" $ git config --global ""

you are now ready to pull, commit, push :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.