Set up git with ssh keys on bitbucket

I found the bitbucket documentation on this a little verbose.

So here is my minimalist guide. I assume that there is already a repo created in bitbucket.

1.  Copy the ssh url from bitbucket. On your repo page there should be a section along the lines of Clone this repository.

Hit SSH and copy the url part (e.g.

2.  On the local machine:

    $ git remote set-url bitbucket

3.  Check the remote address:

    $ git remote -v

This should show something like:

    origin (fetch) 
    origin (push)

4.  Now let’s generate a new SSH key. If you already have an SSH key for the machine, then that can be used. These instructions assume this is the first. Go ahead an accept the default location for saving and if you don’t want to be asked for a password each time you push/pull (which is one of the big advantages of using ssh keys), then hit Enter for the passphrase.

    $ ssh-keygen

5.  Go to the public part of the saved key. It’s probably in /home/.ssh/ Copy it.

6.  Now, on the bitbucket site, go to user->account->ssh keys, and paste the key into the box. Label the key something logical.

7. Back on the local machine:

    $ git push origin master

This should push your repo as normal, but using the SSH protocol and without the need for a password.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s