Multiple SSH accounts for Github

Step 1. Generate ssh keys using command:

Remember to specify different path to both of that keys!

Step 2. Add public keys to github

Step 3. Add keys to the agent

Step 4. Config

Create a ~/.ssh/config file with the content similar to:

Step 5. Test

Step 6. Folders

Create folders for your private and work projects, eg:

Step 7. Git config

Open ~/.gitconfig file and make sure it looks somehow similar to:

Step 8. Git accounts config

Create a new config file (eg. ~/.gitconfig.work) for each github account with a content such as:

Step 8. Files

Let's copy the ./add.sh file into all the ~/priv/ and ~/work/ folders. Also in each of these locations create the .env file containing a single environmental variable, like so:

Step 9. Execute

Simply run the script:

Now if you commit things from, say private folder, the private ssh/git config will be used, likewise the work folder.

Partly taken from here