Contents

SSH-Key Based AuthN Github

How about managing multiple GitHub accounts locally using SSH Keys?

In the real world, you must work with multiple GitHub accounts: one for open-source contributions, another for personal projects, and probably one more for your corporate tasks.

Note
The following diagram illustrates the setup

Figure1: Diagram

Watch me demontrate the task over a video HERE

Tip
The commands being used in the video are as follows;
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
ssh-keygen -t ed25519 -C "youremail" -f "<github-username>"
ssh-keygen -t ed25519 -C "youremail" -f "<github-username>"

#Add keys to SSH Agent:
eval "$(ssh-agent -s)"

ssh-add ~/.ssh/<github-username>
ssh-add ~/.ssh/<github-username>

#SSH Config:

#Personal Account
     Host github.com-<github-username>
          HostName github.com
          User git
          IdentityFile ~/.ssh/<github-username>

#New Account
       Host github.com-<github-username>
            HostName github.com
            User git
            IdentityFile ~/.ssh/<github-username>
			
			
#Test SSH Connectivity:

#First Account:
ssh -T git@github.com-<github-username>

#Second Account:
ssh -T git@github.com-<github-username>

#Set Remote Origin:

github.com-<github-username>:<github-username>/<repo>.git

git@github.com-<github-username>:<github-username>/<repo>.git