How to clone a repository created in Bitbucket.org

How to clone a repository created in Bitbucket.org


The hosting with which you want to do this cloning must have the SSH and GIT service on the dashboard.

First of all, it must activate the SSH hosting. You must only go to the management of your hosting and assign a password for your SSH access.

Then you have to activate the GIT of hosting from the same management.


Once you already have SSH and GIT active, if hosting is ready to start the bitbucket cloning process.

How to create a repository in Bitbucket
Now you must register and create the repository in Bitbucket You can click on this link to access your website directly.

Once you have registered with Bitbucket you can already create your repository.

From your Bitbucket user's homepage, you should go to "Repositories" as shown in the picture:


Then go on "Create a repository":


The system will now ask you for all the data for this new repository:


Mainly, you must assign the name of repository (In the example image the name is "test") and assign the Access level of it, which is whether you want the repository to be public or private, we recommend leaving it marked.

Once all the data is put on "Create repository" and you will already have the repository created.

You have all the information on how to do it in your support page

How to clone a repository in Bitbucket to cdmon hosting
Once the repository has been created, it is time to access cdmon hosting to begin cloning it. This requires SSH access to hosting. To do so you must open your terminal or command line of your operating system. In this example we will use the Windows Power Shell which is installed by default on all Windows systems:


As soon as you open the application you must launch the command of SSH to make the connection to hosting.

The command must be ssh name_ssh@IP_hosting

If the data is correct, the program will ask you for the password you have put when you activated the SSH and if it automatically coincides it will already show the time you have made the connection.

We show an example by making the connection.


It is now connected by SSH to its cdmon hosting. Let's check the files and folders that may have created. To do so, you only need to run the command ls - the and the terminal will list all the files it finds in this direction:


To cloning with bitbucket it is necessary to have a folder created called ssh. It is possible that if you have accessed other times, but if this is the first time you access (as in the example image) this folder will not be created, we must only create it manually.

The command you must launch is mkdir .ssh


When you run it the terminal will not give any message, it will create the folder directly. Now if you do again ls - the you can see that the folder created already appears.
You must now enter this folder. To move between directories, the command is used cd. In this case the command will be cd ssh


As when you have created the folder, the terminal will not confirm that it has entered the folder, it simply accesses.

With this we already have the folder so that bitbucket can connect to our hosting, but having to establish an SSH connection externally requires a specific security key for bitbucket.

To create this security key you must launch the command ssh-keygen. As soon as the system will ask you to indicate the name where you want to save this key, here you must name bitbucket_rsa. In conclusion, you will be asked to enter what password you want to assign to this file, you must put it twice in order to confirm it:


If the two sentences coincide, the terminal must indicate a message such as the following:


With these steps we already have the connection folder and the security key created, now we only need to make Bitbucket find all this information. This requires creating a configuration file in this folder.

The command is used for creating and editing files I saw. In this case the command will be vi config as we show:


Pressing Enter will open the server's text editor. Here you must paste the text shown below:

Host bitbucket.org Hostname bitbucket.org IdentityFile ~/.ssh/bitbucket_rsa IdentitiesOnly yes

It should look like this and how we show in the picture below. If you prefer, you can write it manually.

Once added, you must exit and save the changes to the file. To do this, you must press the key Esc from the keyboard and type :wq as you can see at the end of this photo:


With this you already have all the files and folders created in your hosting, now we have to set up the security key that we have created a few steps earlier in Bitbucket.
To do this, we need to copy the content of the security key that has been saved in the file bitbucket_rsa.pub which has previously been created. Just launch the command cat bitbucket_rsa.pub and you have to copy absolutely all the code that shows you:


Once you have copied, you must minimize the terminal and have to reopen your Bitbucket dashboard.

From any Bitbucket window, you must go to the top right of your website and access the setup wheel and then click on Personal Bitbucket Settings


Then you have to go to the left side of your personal settings, to the "Security" section and access to SSHs keys. Once there you just have to click on the blue button of Add key:


Automatically, a new window will open so you can add our security key. On label you must name the file where we have this key (bitbucket_rsa) and in Key you have to paste all the code we have copied before minimizing the terminal:


Once the data is put on, you only need to click on "Add key" for the information to be saved.

If you have added it correctly, this window must be closed and now we will be able to see in our SSH Keys configuration as listed above:


With all these steps we have now authorized Bitbucket to make changes to our hosting via SSH. Now it is only to clone the repository you have created with hosting.

In order to do so, you have to access the management of the repository you have created, i.e. Repositories as it has been done at the beginning. As soon as you are inside your repository, you should only go to the top right of it, where a button appears Clone:


Clicking there will open a window with an SSH command already drafted. All you need to do is copy the command, there is even a button to be able to do so with a single click:


Already to finish, you just need to reopen the terminal and paste this command and press Enter to run it.

If you detect the correctly configured SSH key, the terminal will ask you to enter the security key you have assigned when you created it. In putting it correctly, it will take a few seconds to cloning, but it must finally indicate that all the "objects" have been received and that it has ended smoothly.


Finally, if you do again als - the To list the files and folders inside, you can see that the name of the repository you created in Bitbucket appears:


With all these steps he has already cloned a repository created in Bitbucket to its SSH user.

You can click on this link to access our guide on how to use GIT commands to replicate changes in Bitbucket


For more information, you can contact us.
    • Related Articles

    • How to use GIT commands with Bitbucket repository

      In this tutorial we will show the steps to take to use the GIT commands to clone files from your hosting in a repository created in Bitbucket with the SSH of their cdmon hosting. First of all, you need to have a repository created in Bitbucket. If ...
    • How to create a GIT repository

      Here's step-by-step how to create and manage a GIT repository from your dashboard. This process is simple and straightforward, allowing you to set up a development environment quickly. Access to hosting Developer hosting Activate developer hosting ...
    • How to deploy GIT repositories

      Our GIT deployment tool allows you to clone and manage GitHub repositories directly from the cdmon dashboard, without using FTP or GIT commands. This makes it easy to install and update projects quickly and easily. To manage GIT repository ...
    • Staging: create test environments without affecting your main website

      The tool ofStaging(or test environment) allows you to create afunctional copy of your websitein an isolated environment. It is ideal for doingtests, apply updates or make changeswithout affecting your main website. Enter the control panel Access the ...
    • How to access the test platform

      Access to the Test Platform is done just like access to any hosting, through the "Basic List of Services" or from the "List of Hosted Plans" in the cdmon Control Panel. Access from the Basic List of Services Access from the List of Hosted Plans Once ...