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
push, because... why not?.
Well, if you are doing it so, let me tell you that:
- You are wasting your precious time
- You are typing more that should be
- Please, stop doing that
So, let's get started!
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.
Open your terminal (or Git Bash if you are using Windows) and type:
ssh-keygen -t rsa -b 4096 -C "firstname.lastname@example.org"
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 email@example.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.
Just to be sure, let's see the content of the file with this command (applies for Windows users too):
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== firstname.lastname@example.org
That's your SSH key.
Log into Bitbucket and search your user icon:
Now click on Bitbucket settings option:
Now click on SSH keys option:
Now press the Add key button. If you previously configured a SSH key then it will be listed (like mine):
For last, enter whatever name you'd like and paste the content you saw on step 2:
And that's all. Very easy isn't?
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:
For last, just clone your repository and be happy 😁: