Create different public key #
According the article Mac Set-Up Git (opens new window)
$ ssh-keygen -t rsa -C "your_email@youremail.com"
1
For example, 2 keys created at:
~/.ssh/id_rsa_hungthai1401
~/.ssh/id_rsa_thai.nguyenhung
1
2
2
Then, add these two keys as following
$ ssh-add ~/.ssh/id_rsa_hungthai1401
$ ssh-add ~/.ssh/id_rsa_thai.nguyenhung
1
2
2
You can delete all cached keys before
$ ssh-add -D
1
Finally, you can check your saved keys
$ ssh-add -l
1
Modify the ssh config #
$ cd ~/.ssh/
$ touch config
$ subl -a config
1
2
3
2
3
Then added
#hungthai1401 account
Host github.com-hungthai1401
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa_hungthai1401
#thai.nguyenhung account
Host github.com-thai.nguyenhung
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa_thai.nguyenhung
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
Clone you repository and modify your Git config #
git clone git@github.com-hungthai1401:hungthai1401/til.git til
1
cd til and modify git config
$ git config user.name "Thai Nguyen Hung"
$ git config user.email "hungthai1401.it@gmail.com"
1
2
2
Then use normal flow to push your code
$ git add .
$ git commit -m "your comments"
$ git push
1
2
3
2
3
Comment