Configuring SSH Key for Bitbucket repositories
Tags: ssh, git
Published: 2018-09-19 04:50:13

---
title: Configuring SSH Key for Bitbucket repositories
published: true
description: How to configure your SSH key into Bitbucket repositories
tags: ssh,git
cover_image: https://thepracticaldev.s3.amazonaws.com/i/welg9iptxtg3rn04vin9.png
---

It's pretty common that beginner developers get used to do the same thing over and over again, more specific, log into bitbucket server every `pull` and `push`, because... why not?.

Well, if you are doing it so, let me tell you that:

1. You are wasting your **precious** time
2. You are typing more that should be
3. Please, stop doing that

So, let's get started!

## Step 0: Install Git

I'm assuming you did this before 😒, doesn't matter if you are using Windows or Linux but if you are using Windows... **PLEASE INSTALL GIT BASH**.

## Step 1: Create the file `id_rsa.pub`

Open your terminal (or Git Bash if you are using Windows) and type:

```bash
ssh-keygen -t rsa -b 4096 -C "your@email.com"
```

If you did it well then this should appear:
```
Generating public/private rsa key pair.
Enter file in which to save the key (/home/<your-user>/.ssh/id_rsa):
```
From this point you need to do just one thing... **PRESS ENTER OVER AND OVER AGAIN** to get this:

```
Created directory '/home/<your-user>/.ssh'.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/<your-user>/.ssh/id_rsa.
Your public key has been saved in /home/<your-user>/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:lXhYzNtK37chmNGsV5/278yr6LrWuUygcYvqklcdtzI my.email@gmail.com
The key's randomart image is:
+---[RSA 4096]----+
|         o.      |
|         +o.     |
|        o +oo    |
|         +oo.o . |
|       .S+oo*.. o|
|       .=E+=.o.+o|
|    . .o .+.o o.+|
|   o ..  .oo.  +.|
|    +o  .o+=...oB|
+----[SHA256]-----+

```

A file called `id_rsa.pub` was created.

## Step 2: Check if you did it well

Just to be sure, let's see the content of the file with this command (applies for Windows users too):

``` bash
cat ~/.ssh/id_rsa.pub
```

And you should see something like this:

```
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDKk+oiraZNtLEOsnoipb2vQneDKEu/KRjkimYucyrISkELCIqudGDhPyOxsKDIh61+tkoufJ6l0i9OCWVF/ckF2b8EZmqDLPIQR0x3Idg8vkmYS+aD/DdeUDrCYOR0rWXrCAdOOMJrkuoN0z+rFEGHW+Lkx8JqIwUm237RVOnJy9g8XG9bpRjjNZGLvhVIR0rmNtJ3NdEHZTrXmkookIU1/XTr/WVn6W7L695yyIYonNGczDrhAmnqYFm6HQabb4NTUm37PiZRxbkiJLjAo44AMM+4FhUrYN9FJkfgSqa3yJAYAGwFxRarw0JiG5yocXMLfP3kkcpfXrSxB2hz4D3U3Mw814tcUlLYQtcJN0kzO5qSUWfXeedZsmQw5p2zwlcrLcXeIvOleupvK+H+r7CW2Efvq/GZtZUytwgO1J2uOrs8RBZMWTYjz1qXOmC03V7Kft3Mcn9udGmuDB9nWuPJi8wl9UyHT/hUpJi4g/n9hazulnToM9mBOi82x2aMvcbnapsPk5dMFmh3lZylAs/szQwYbR05Qu6UXZxoZXWsoZds4O/RrXIsyViw6FKLvO2diJlDNuDu9fg4FK5kbOEktqqi6h3pY8QtJEM7I1iiKUeZVzinswn0Xh7bwEOduT+aZ79J99MV8pav6EsBEEIi+9qFbcuzIMTKrqcUYfOWOw== my.email@gmail.com

```

That's your **SSH key**.

## Step 3: Configure your SSH key into Bitbucket (similar applies to Github)

Log into [Bitbucket](www.bitbucket.org) and search your user icon:

![#1 Search your user icon](https://thepracticaldev.s3.amazonaws.com/i/40waihj872lwzahnhrkm.png)

Now click on _Bitbucket settings_ option:

![Click that option](https://thepracticaldev.s3.amazonaws.com/i/t4m3d3x6am4v4xaodprl.png)

Now click on _SSH keys_ option:

![Click that option](https://thepracticaldev.s3.amazonaws.com/i/u2wcmdxualmchg7gb42q.png)

Now press the _Add key_ button. If you previously configured a SSH key then it will be listed (like mine):

![Press the button](https://thepracticaldev.s3.amazonaws.com/i/txiuxth6gu9akto1bdfo.png)

For last, enter whatever name you'd like and **paste the content you saw on step 2**:

![Press save](https://thepracticaldev.s3.amazonaws.com/i/nxguns78en77fd76j6fa.png)

And that's all. Very easy isn't?

## Step 4: Clone your repository using SSH protocol

It's time to proof that you did it well, so create or go to any repository and press _Clone_ button. You should see the SSH option selected:

![Press clone button](https://thepracticaldev.s3.amazonaws.com/i/tqonb9ntz5irguvqm44j.png)

For last, just clone your repository and **be happy** 😁:

![Be happy](https://thepracticaldev.s3.amazonaws.com/i/vlygkwmj214e8rn0tkac.png)