DEV Community

Cover image for Configuring SSH Key for Bitbucket repositories
Jorge Ram贸n
Jorge Ram贸n

Posted on

Configuring SSH Key for Bitbucket repositories

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

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

ssh-keygen -t rsa -b 4096 -C ""
Enter fullscreen mode Exit fullscreen mode

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):
Enter fullscreen mode Exit fullscreen mode

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/
The key fingerprint is:
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|

Enter fullscreen mode Exit fullscreen mode

A file called 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):

cat ~/.ssh/
Enter fullscreen mode Exit fullscreen mode

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==

Enter fullscreen mode Exit fullscreen mode

That's your SSH key.

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

Log into Bitbucket and search your user icon:

#1 Search your user icon

Now click on Bitbucket settings option:

Click that option

Now click on SSH keys option:

Click that option

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

Press the button

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

Press save

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

For last, just clone your repository and be happy 馃榿:

Be happy

Top comments (5)

agusescobar profile image

Thanks <3

jrrrsmith profile image
Jeremy Smith

Thank you! Huge help, I've been struggling with this all morning.

subirats345 profile image
Joan Subirats Llaveria


rudyvogt profile image

Hi, great article, but i have tried using SSH, but can't get it to work

getting an error:
ssh: connect to host port 22: Network is unreachable

jorge_rockr profile image
Jorge Ram贸n

Hi! Thanks for your feedback.

That error happens when you try to clone a repository?

Are you sure that you have internet access? (Try ping command to check)