You can generate different SSH keys for different Bitbucket accounts, for example, and configure them in ~/.ssh/config to use one or the other based on hostnames.

This config file will point a custom hostname to bitbucket.org (continuing the example), but specify a key different from the default. Assuming the key is saved to ~/.ssh/id_rsa_secondary:

# This uses the default key
Host bitbucket.org
  User git
  Hostname bitbucket.org
  PreferredAuthentications publickey
  IdentityFile ~/.ssh/id_rsa

# This uses the secondary one
Host bitbucket-2
  User git
  Hostname bitbucket.org
  PreferredAuthentications publickey
  IdentitiesOnly yes
  IdentityFile ~/.ssh/id_rsa_secondary

Cloning a repo with the secondary account looks like this:

$ git clone git@bitbucket-2:username/repo.git

Previous on Linux
Mastodon Mastodon