Create different ssh keys according to the article Generating a new SSH key and adding it to the ssh-agent
$ ssh-keygen -t ed25519 -C "[email protected]"
Please refer to github ssh issues for common problems.
for instance, you have created the following keys:
~/.ssh/id_ed25519_w
~/.ssh/id_ed25519_p
then, add these two keys as following
$ ssh-add ~/.ssh/id_ed25519_w
$ ssh-add ~/.ssh/id_ed25519_p
you can delete all cached keys before
$ ssh-add -D
finally, you can check your saved keys
$ ssh-add -l
copy your ssh key
$ xclip -sel clip < ~/.ssh/id_ed25519_p.pub
$ cd ~/.ssh/
$ touch config
$ nano config
Then add
# work account
Host github.com work-login
HostName github.com
User git
IdentityFile ~/.ssh/id_ed25519_w
# personal account
Host github.com personal-login
HostName github.com
User git
IdentityFile ~/.ssh/id_ed25519_p
clone your repo git clone [email protected]:perconal-login/repo_name.git
cd repo_name and modify git config
$ git config user.name "work-login"
$ git config user.email "[email protected]"
$ git config user.name "personal-login"
$ git config user.email "[email protected]"
or you can have global git config
$ git config --global user.name "work-login"
$ git config --global user.email "[email protected]"
then use normal flow to push your code
$ git add .
$ git commit -m "your comments"
$ git push