# ~/.ssh/config
Host {work}.bitbucket.com
HostName {work}.bitbucket.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/{work}
Host bitbucket.org
HostName bitbucket.org
PreferredAuthentications publickey
IdentityFile ~/.ssh/personal
Host github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/personal
# Using multiple SSH keys for same domain
# It works as alias. Use it for git clone for example "git clone git@other.github.com/USER/REPO"
Host other.github.com
Hostname github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/private
# Generate keys to their specific files
ssh-keygen -t rsa -C "{email}" -f "{file_name}"
# or
ssh-keygen -t ed25519 -C "{email}" -f "{file_name}"
Add keys to respective hosts
Test auth status using ssh -T git@github.com
or ssh -T git@other.github.com