Generate SSH Keys for Each Bitbucket Account
- Generate SSH key for Software Company account:
ssh-keygen -t ed25519 -b 4096 -C "john.doe@softwarecompany.com" -f ~/.ssh/softwarecompany
- Add each private key to the SSH agent, such as:
ssh-add ~/.ssh/softwarecompany
- Add the generated public key (
softwarecompany.pub
) to the Bitbucket account’s SSH settings. - Generate SSH key for Tech Company account:
ssh-keygen -t ed25519 -b 4096 -C "john.doe@techcompany.com" -f ~/.ssh/techcompany
- Add each private key to the SSH agent, such as:
ssh-add ~/.ssh/techcompany
- Add the generated public key (
techcompany.pub
) to the Bitbucket account’s SSH settings.
Configure SSH Config File
- Open the SSH configuration file in a text editor:
nano ~/.ssh/config
- Add the following entries for each Bitbucket account:
Host softwarecompany
HostName bitbucket.org
IdentityFile ~/.ssh/softwarecompany
Host techcompany
HostName bitbucket.org
IdentityFile ~/.ssh/techcompany
Cloning Repositories
When cloning repositories, replace the default host with the configured host:
- For Software Company:
git clone git@softwarecompany:myworkspacesoftwarecompany/myrepo.git
- For Tech Company:
git clone git@techcompany:myworkspacetechcompany/myanotherrepo.git
Ensure to replace bitbucket.org
with the appropriate configured host. You’re all set! This setup allows you to work with multiple Bitbucket accounts on a single device seamlessly.