Github ssh multiple accounts & users for separate projects

Use multiple accounts for separate github projects.

Create private and public keys. This command will create an RSA key with an empty comment (as it's not required). Run this command and save the id_rsa file using different names for each project.

$ ssh-keygen -t rsa -C ""

Edit the ssh config to add separate configurations for each project.

$ vim ~/.ssh/config

Add your first project to the configuration.

User git
IdentityFile ~/.ssh/some-project_id_rsa

Add the second project to the configuration. The "Host" in each ssh configuration group needs to be unique.

User git
IdentityFile ~/.ssh/another-project_id_rsa

Clone the project. Note that we are using a modified clone command that uses the "Host" specified in the configuration (""). Also set the user name and email for the project that will be used when committing changes.

$ cd ~/Projects
$ git clone
$ cd ~/Projects/some-project
$ git config "some-project"
$ git config ""

Repeat the git clone for the next project. This time changing the "Host" again to the other project's "Host" specified in the configuration.

$ cd ~/Projects/
$ git clone
$ cd ~/Projects/another-project
$ git config "another-project"
$ git config ""
If you liked this posting, please feel free to leave me a comment below.
View this page on GitHub.
Posted .

1 comment

  1. anonymous
    The .git/config files should look similar to this: For project A: [remote "origin"]     url =     fetch = +refs/heads/*:refs/remotes/origin/* For project B: [remote "origin"]     url =     fetch = +refs/heads/*:refs/remotes/origin/*

Leave a Reply