Skip to content

Instantly share code, notes, and snippets.

@romixch
Last active November 13, 2019 15:56
Show Gist options
  • Save romixch/f38a9d2975d4656dd145394780afb30a to your computer and use it in GitHub Desktop.
Save romixch/f38a9d2975d4656dd145394780afb30a to your computer and use it in GitHub Desktop.
Configure git for bitbucket.org and github.com

Bitbucket

Generate ID for bitbucket

ssh-keygen

By default, this is stored at ~/.ssh/id_rsa. Change this to ~/.ssh/bitbucket_id_rsa

Now configure ssh to use your bitbucket id when talking to bitbucket.org. Following text should go into ~/.ssh/config. If the file does not exist, create it:

Host bitbucket.org
  UseKeychain yes

Add ssh key to the ssh-agent:

eval `ssh-agent`

On Mac:

ssh-add -K ~/.ssh/bitbucket_id_rsa

On Linux:

ssh-add -K ~/.ssh/<bitbucket_id_rsa

Now we need to tell bitbucket your public key so they can verify that it's you:

cat ~/.ssh/bitbucket_id_rsa.pub

Copy the output of the command above and add a new key on bitbucket: (https://bitbucket.org/account), ssh keys.

Now you can even test your configuration:

ssh -T git@bitbucket.org

GitHub

Generate ID for Github

ssh-keygen

By default, this is stored at ~/.ssh/id_rsa. Change this to ~/.ssh/github_id_rsa

Now configure ssh to use your github id when talking to github.com. Following text should go into ~/.ssh/config. If the file does not exist, create it:

Host github.com
  UseKeychain yes

Add ssh key to the ssh-agent:

eval `ssh-agent`

On Mac:

ssh-add -K ~/.ssh/github_id_rsa

On Linux:

ssh-add -K ~/.ssh/<github_id_rsa

Now we need to tell github your public key so they can verify that it's you:

cat ~/.ssh/github_id_rsa.pub

Copy the output of the command above and add a new key on github: (https://github.com/settings/profile), Security, SSH and GPG Keys, SSH Keys.

Now you can even test your configuration:

ssh -T git@github.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment