Source: https://confluence.atlassian.com/bitbucket/set-up-an-ssh-key-728138079.html
- Run SSH key generator:
ssh-keygen
- Save key to default location (
/Users/name/.ssh/id_rsa
) - Add a passkey/phrase
- Ignore the output which prints to Terminal
- Check that the
id_rsa
(private) andid_rsa.pub
(public) keys were generated:
cd ~/.ssh
ls
Source: https://confluence.atlassian.com/bitbucket/set-up-an-ssh-key-728138079.html
- Start the agent:
eval `ssh-agent`
- Add the private key:
ssh-add -K ~/.ssh/id_rsa
- Create a config file:
cd ~/.ssh
touch config
nano config
# Enter the following
Host *
AddKeysToAgent yes
UseKeychain yes
IdentityFile ~/.ssh/id_rsa
Note: I initially missed the UseKeychain
step in the Bitbucket instructions.
The other lines come from the page that helped me resolve this: Source Tree SSH Public Key Denied
.
- Copy the public key to the clipboard:
pbcopy < ~/.ssh/id_rsa.pub
- Log in to https://bitbucket.org/
- Click on your avatar
- Select Security > SSH Keys
- Click Add key
- Paste the key and name appropriately
- Copy the public key to the clipboard:
pbcopy < ~/.ssh/id_rsa.pub
- Log in to https://github.com/
- Click on your avatar
- Select Settings
- Select SSH and GPG keys
- Click New SSH Key
- Paste the key and name appropriately
- Open Sourcetree
- Window > Show Repository Browser
- Click the gear icon and select Accounts
- Add > Host > Bitbucket
- Select the defaults of OAuth, SSH, SSH Key:
id_rsa.pub
- Click Connect Account
Repeat as for Bitbucket
ssh -Tv [email protected]
- Open a private repo page on Bitbucket > click Clone > copy the
git clone ..
command and run in Terminal - Open a private repo page on Bitbucket > click Clone > Clone in Sourcetree
- Sourcetree > Git - Preferences > Git > Reset to Embedded Git (already set)