github multiple accounts setup notes

key generation and registration

The way github identifies you is thru your ssh keys (public keys need to be registered at github & private keys live on your machine). The way to generate keys is to find ssh-keygen, it comes handy with git bash

$ ssh-keygen -t rsa -C ""
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/sarangb/.ssh/id_rsa): id_rsa_tempuser1
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in id_rsa_tempuser1.
Your public key has been saved in
The key fingerprint is:
The key's randomart image is:
+---[RSA 2048]----+
|         ..**+.o |
|         .+.==o.o|
|       ..oo..=+++|
|      ...o..ooB=o|
|      o.S . o+.+.|
|     o o.   ..+  |
|    . . .E o   . |
|      . +.o .    |
|       +oo       |

And now i have new keys in my ~/ directory, on windows that translate to user-home directory. i moved the keys to ~/.ssh directory just to be consistent:

$ ls -lrt ~/.ssh/
total 28
-rw-r--r-- 1 sarangb 197121  803 Nov 27 21:10 known_hosts
-rw-r--r-- 1 sarangb 197121  203 Mar  4 11:21 config
-rw-r--r-- 1 sarangb 197121 1766 Mar  4 11:36 id_rsa_tempuser1
-rw-r--r-- 1 sarangb 197121  400 Mar  4 11:36

Now to here id_rsa_tempuser1 has private key and has public key portion. Head over to, in your profile settings register the public keys with appropriate caption.

clip < ~\.ssh\

The best way to do so is to use clip command in git-bash (note copy only public keys), this would copy it on clipboard.

setting up config files

Now that we have multiple keys generated, it is time to associate keys with accounts in config file. vim to \.ssh\config or create one at location if it does not exists already and add your keys to your user. Here i have added a temporary Host github-repositories-tempuser1 with user tempuser1. Note you can have multiple users to same hostname

Host github-repositories-tempuser1
    User tempuser1
    IdentityFile ~/.ssh/id_rsa_tempuser1

Host github-angeleno
    User angeleno
    IdentityFile ~/.ssh/id_rsa_angeleno

Once you setup and to appropriate user and setup remote url properly: git remote add origin git@github-repositories-tempuser1:tempuser1/repository1.git you should be able to push changes as designated user.


git  ssh