Skip to content

Instantly share code, notes, and snippets.

@muzfuz
Last active December 22, 2015 21:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save muzfuz/b80fab92e68eb111fbb5 to your computer and use it in GitHub Desktop.
Save muzfuz/b80fab92e68eb111fbb5 to your computer and use it in GitHub Desktop.
Configure SSH keys for both Bitbucket and Github

#Instructions for enabling your local machine to use both BitBucket and GitHub

Ok, so you want to configure your machine to use BitBucket. The options are:

  1. Use the SourceTree Client
  2. Configure SSH to use git with Terminal

The first one is self explanatory, so we will focus on the second one.

If you want to use BitBucket via Terminal, chances are you want to configure SSH, and also are already using GitHub.

The bad news is, BitBucket makes this process just a little bit more difficult, but not by much. The worse news is, that since you are already using GitHub, you need to spend about 30 minutes doing some reading so you can do a proper config on your system.

What you are going to do is generate an SSH key inside your system, configure a BitBucket alias, and then paste that key into your user settings in your BitBucket account page. Here goes:

  1. Open terminal to your root user menu ($: cd ~/)
  2. Run the command ssh-keygen and give your key a name. Something like bitbucket_id should be ok.
  3. Move the two created files (in this case bitbucket_id and bitbucket_id.pub into the ~/.ssh directory.
  4. If you don't have a config file, create a file called config in the ~/.ssh directory.
  5. Add the following config to the file:
Host bitbucket.org
	HostName bitbucket.org
	PreferredAuthentications publickey
	IdentityFile ~/.ssh/bitbucket_id
  1. This config file allows you to store multiple aliases, so you can use GitHub as well as BitBucket from your Terminal automatically, with unique SSH keys for each. (See the links below for more info)
  2. Copy your SSH out of the file you generated, then log into BitBucket, go to your user settings, create a new key and paste it in.
  3. You should now be able to pull from and push to repos.

###You can read more about alias configuration and SSH keys here

And use this article plus this article to fill in any gaps in your knowledge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment