Original Medium Article link: Here
ssh-keygen -t ed25519 -C example_personal_email@example.com -f ed25519_personal
ssh-keygen -t ed25519 -C example_work_email@example.com -f ed25519_work_gl
ssh-keygen -t ed25519 -C example_work_email@example.com -f ed25519_work_gh
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/ed25519_personal
ssh-add ~/.ssh/ed25519_work_gl
ssh-add ~/.ssh/ed25519_work_gh
# ssh-agent
{ eval `ssh-agent -s` } &>/dev/null
{ ssh-add ~/.ssh/id_ed25519 } &>/dev/null
{ ssh-add ~/.ssh/id_ed25519_personal } &>/dev/null
{ ssh-add ~/.ssh/id_ed25519_gh } &>/dev/null
Copy Public key to clipboard
# Mac
pbcopy < ~/.ssh/ed25519_personal.pub
# Windows
clip < ~/.ssh/ed25519_personal.pub
GitHub and GitLab documentation
For GitHub, navigate over to User > Settings > SSH and GPG keys > New SSH key
For GitLab, navigate over to User > Preferences > SSH Keys
cd ~/.ssh/
touch config
nvim config // Opens the file in Neovim, feel free to use your preferred editor
Add relevant entries to config file
# Personal account
Host github.com
Hostname github.com
User git
IdentityFile ~/.ssh/ed25519_personal
# Work GitLab account
Host gitlab.com
Hostname gitlab.com
User git
IdentityFile ~/.ssh/ed25519_work_gl
# Work GitHub account
Host github.com-work
Hostname github.com
User git
IdentityFile ~/.ssh/ed25519_work_gh
ssh -T git@github.com
ssh -T git@gitlab.com
ssh -T git@github.com-work
[user]
name = <your_username>
email = <your_email>
[includeIf "gitdir:~/GitLabWorkPath/"]
path = ~/GitLabWorkConfigPath
[includeIf "gitdir:~/GitHubWorkPath/"]
path = ~/GitHubWorkConfigPath
For each config path
[user]
name = <your_work_username>
email = <your_work_email>