JMU JMU - Department of Computer Science
Help Tools
Creating a Bitbucket Repository


1 Creating an Account

You can create an account at bitbucket.org.

2 Adding an SSH Key to an Account

Git uses Secure Shell (SSH), a protocol that provides secure network services. SSH uses public-key encryption, hence you must first create a key-pair (that consists of a public key and a private key) and then add the key to Bitbucket.

2.1 Checking for an Existing Key-Pair

You may already have a key-pair (that was created for some other purpose). If so, you should use it.

To check, navigate to your home directory (e.g., \users\username in MS-Windows, ~ in Unix/Linux) and see if you have an .ssh directory/folder (note the period) that contains the files id_rsa (the private key) and id_rsa.pub (the public key). If you have these files then you do not need to create a key-pair.

2.2 Creating a Key-Pair

You can create a key-pair using the ssh-keygen utility from a command shell (or, in MS-Windows, using the PuTTY Key Generator).

In Unix/Linux and OS X, the ssh-keygen utility is available from the "normal" BASH shell. In MS-Windows, the CMD shell does not have an ssh-keygen utility so you need to use the MSYS/MINGW shell instead (or the PuTTY Key Generator). If you've installed MSYS/MINGW independently, you know how to start the shell. If not, but you've installed Aptana Studio, you can start the shell by navigating to /Users/username/Documents/Aptana Studio 3 Workspace/.metadata/.plugins/com.aptana.portablegit.win32 (where username is your username on your computer) and clicking on git-bash.bat.

Now, enter the command:

ssh-keygen -t rsa -C "Generated date"

where date is the date. (Note: The -C flag is a comment.)

Press Enter in response to the first prompt, and enter a passphrase in response to the next two prompts.

2.3 Viewing/Copying your Public Key

In Unix/Linux and the MSYS/MINGW you can look at your public key using the command cat ~/.ssh/id_rsa.pub. You can then click and drag and copy the key to the clipboard. (In MS-Windows right-click on the title bar and pull down to Edit-Mark to start the process.) In OS X you can copy your public key to the clipboard using the command pbcopy < ~/.ssh/id_rsa.pub.

2.4 Adding a Key

Click on your avatar (on the top fight of the Bitbucket "menu") and pull down to Manage account. Then, click on SSH keys. Enter "Default Public Key" in the Label field and paste your public key (i.e., the contents of cat ~/.ssh/id_rsa.pub) into the Key field. Finally, click on Add.

2.5 Testing the Key

You can test your key from the command shell by typing the command ssh git@bitbucket.com and entering your passphrase. You should get a message that indicates that the authentication worked but that you don't have shell access.

2.6 For More Information

For more information/help see the Bitbucket documentation.

3 Creating a Repository

To create a repository, click on Repositories-Create then give it a Name, set the Repository type to Git, and click on Create repository.

To get the URL of the repository, click on Overview and get started and "I have an existing project to push up". The URL will be in the git remote add origin command.

Copyright 2019