Lots of companies are using Github nowadays for hosting their private repositories. If you are like me and you don't like mixing up your public/private personas, you might want to have a couple of Github accounts, one for business and one for your personal matters.

Let's see how to achieve this.

Create your SSH keys

In this case, I’ll be creating two SSH keys, one for loalf (my public profile) and another one for humandb (the corporate one).

$ ssh-keygen -t rsa -b 4096 -C "personal_email@youremail.com"
$ ssh-keygen -t rsa -b 4096 -C "company_email@youremail.com"

Two keys will be created

~/.ssh/id_rsa_humandb
~/.ssh/id_rsa_loalf

Modify your SSH config file

Next, you’ll have to edit your SSH config file. You config file should be at ~/.ssh/config. If it doesn’t exist, just create it.

Host loalf.github.com
    HostName github.com
    User git
    IdentityFile ~/.ssh/id_rsa_loalf

Host humandb.github.com
    HostName github.com
    User git
    IdentityFile ~/.ssh/id_rsa_humandb

Clone your repository

If you want to clone one of your repositories as loalf you now do

git clone git@loalf.github.com:loalf/your-repo.git

Note that instead of using github.com as the host, we’re using loalf.github.com instead.

Set up your username and email address

Change your git username and email address within the project.

$ git config user.name "loalf"
$ git config user.email "f12loalf@gmail.com"