Github will be the main account and bitbucket the secondary.
Use Homebrew to install Git.
git config --global user.name "Your Name"git config --global user.email "username@email.com"
Confirm changes: git config --global -l
ssh-keygen -t rsa -C "github email"
Enter passphrase when prompted. If you see an option to save the passphrase in your keychain, do it for an easier life.
Save keys to:
~/.ssh/id_rsa
Repeat for bitbucket:
ssh-keygen -t rsa -C "bitbucket email"
Save bitbucket key to ~/.ssh/id_rsa_bb
Login to remote repo and add ssh key:
pbcopy < ~/.ssh/id_rsa.pub
pbcopy < ~/.ssh/id_rsa_bb.pubObviously run each pbcopy command individually.
Paste into text area, under ssh settings, in your github or bitbucket account. Also give the ssh key a title like "your name" Laptop.
I am using vim, enter your editor here if different:
vim ~/.ssh/config
Create your git aliases like so:
#Github (default)
Host gh
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa
#Bitbucket (secondary)
Host bb
HostName bitbucket.org
User git
IdentityFile ~/.ssh/id_rsa_bbNote: On Mac OS Sierra onwards you have to add this to the top of the config file:
Host *
UseKeychain yes
AddKeysToAgent yesssh-add ~/.ssh/id_rsa
ssh-add ~/.ssh/id_rsa_bbEnter passphrase if prompted.
Check keys were added:
ssh-add -l
ssh -T gh
ssh -T bbbitcoin:bc1q95kxs25a6d7fp8prqdmgm6sstjxav8q959t30u