5 ms·
Different addresses for different repos are pretty straightforward. Can someone tell me please how to use multiple SSH keys. I have constant problem with Bitbuc
by AndyJames 4y ago
Different addresses for different repos are pretty straightforward. Can someone tell me please how to use multiple SSH keys. I have constant problem with Bitbucket because they require SSH key to be unique across whole platform. I work on many projects. Some companies require me to use Bitbucket account created by them with their email address. I can't add my SSH key to such account because it's already assigned to my private account. My workaround is to use GitKraken which allows assigning SSH keys per repo but I would really like to have this option in command line and don't need full GitKraken license just for pushing changes
- rad_gruchalski 4y agoI do it like this: https://gruchalski.com/posts/2022-04-28-private-go-modules-with-multiple-git-identities/ https://gruchalski.com/posts/2022-04-28-private-go-modules-w.... This is in the context of go modules but it works with regular git stuff.
- terinjokes 4y agoYou can use something like direnv to export GIT_SSH to point at a wrapper that invokes `ssh -i ~/.ssh/id_corp $@`.
- olddustytrail 4y agoThere's an option in newer git. For cloning new repo: git clone -c "core.sshCommand=ssh -i ~/.ssh/bitbucket-work -F /dev/null" git@bitbucket.com:example/example For existing repo: git config core.sshCommand "ssh -i ~/.ssh/bitbucket-work -F /dev/null" Where "bitbucket-work" is the name of the key for that particular repo.
- Macha 4y agoI tend to just configure my .ssh/config file to create an entry for github-companya with host github.com and identity file ~/.ssh/companya (or replace GitHub with bitbucket in your case)
- mleo 4y agoOn BitBucket, at least, you can utilize wildcard DNS and use different hostnames with SSH keys. $ git clone git@workspace.bitbucket.org:workspace/repo.git I haven't tried with GitHub as I only have one account I use there.