How to configure and use a dedicated SSH Key in a Bitbucket  project?

How to configure and use a dedicated SSH Key in a Bitbucket project?

Play this article


SSH stands for "Secure Shell." It is a cryptographic network protocol used to securely access and manage network devices and servers over a potentially unsecured network.

SSH provides a secure way to establish a remote connection to a system, allowing users to execute commands and manage files on a remote machine as if they were physically present at the computer.


You need to have an SSH key added to your Bitbucket project.


List all SSH keys

ls ~/.ssh/


calaca@calaca-PC ~/var/www $ ls ~/.ssh/
config  id_ed25519  known_hosts  ssh_key_adc

Check the content

Select the desired SSH key and review its contents.

cat ~/.ssh/


calaca@calaca-PC ~ $ cat ~/.ssh/
ssh-ed25519 ABADC3NzaC1l0DI1NTE5AAAAIMWf5MaychLIR0mbAvXfpy9IPvrczLr55WTZUu3Tqad

Create a SSH config file

touch ~/.ssh/config

Understand the configuration

In this step, we'll use the Bitbucket project clone link. In my example, I'll use the following clone link

Open the SSH config file

code ~/.ssh/config

I used VS Code Studio to open it, however, you can use your favorite text editor.

Configure the SSH Key config file

Basically, the ssh key config file has 03 components: Host, HostName and IdentifyFile.

Let's start with the easiest: HostName.


Since we're configuring Bitbucket, our HostName is the following:


The previous and the following code snippets must be inside the ~/.ssh/config file.


Here, we're going to insert the path of our private ssh key.

IdentityFile ~/.ssh/ssh_key_adc

So far, we have the following code inside the ~/.ssh/config file.

IdentityFile ~/.ssh/ssh_key_adc


The Host can be virtually anything you want, but I recommend using something like the following:


When you use SSH to connect to a remote server, you typically use the server's domain name or IP address.

However, with this configuration, you're creating an alias for the host configuration that you can use in your SSH commands.

So far, our code looks something like the following:

    IdentityFile ~/.ssh/ssh_key_adc

Review SSH config file

The following is the complete code:

    IdentityFile ~/.ssh/ssh_key_adc

A bitbucket clone link looks like the following:

In order to use our ssh key, we'll have to change that link slightly based on the Host info. The new link would be like the following:

The reason for the change is due to the content of the ~/.ssh/config file:

    IdentityFile ~/.ssh/ssh_key_adc

With this configuration, you're creating an alias for the host configuration that you can use in your SSH commands.

Let's modify the bitbucket clone link in order to apply that, the new bitbucket clone link is going to be:

Clone the project

git clone

Open the folder's project

In my example

cd var/www/my_project_name

Check user associated with repo

git config --list


Being more specific about the user

git config --list --local

The command git config --list --local is used to display the Git configuration settings for the current Git repository at the local level. It specifically lists the configuration settings that are specific to the repository where you run the command.

Remove user associated with repo

git config --local --unset
git config --local --unset

Add new user

git config --local "My new name"
git config --local ""

Check repo info

git config --list --local


You've made it!

The Office GIF - The Office Happy - Discover & Share GIFs

Let's become friends

Final thoughts

I hope this article has been helpful to you. Please feel free to reach out if you have any questions. Your thoughts, suggestions, and corrections are more than welcome.

By the way, don't hesitate to drop your suggestions for new blog articles.

I look forward to seeing you next time