DEV Community

Yamikani Chinamale
Yamikani Chinamale

Posted on

Cloning a BitBucket Repo


I have a repo called 'my-new-repo' on BitBucket. I'm going to walk you through the steps I took in order to clone that repo onto my machine.


First, set up an rsa key pair.

$ ssh-keygen
Generating public/private rsa key pair.
Enter fullscreen mode Exit fullscreen mode

You have to assign a name to the key. You could choose to leave this section blank to give it the default name; it will also get saved in the default location. I chose to name mine 'wsl-default' and saved it in my current working directory.

Enter file in which to save the key (/home/yamikani/.ssh/id_rsa): wsl-default
Enter fullscreen mode Exit fullscreen mode

For the purpose of this walkthrough, go ahead and leave the passphrase empty. The interaction should look something like this

Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in wsl-default.
Your public key has been saved in
The key fingerprint is:
SHA256:TosAyiMu6LNeibN4K+aGxwIXGzWgLsuL5peR+isxbc4 yamikani@LAPTOP-HBMDC5G1
The key's randomart image is:
+---[RSA 2048]----+
|  ..             |
| .  o            |
|. .. .           |
|o.o.             |
|++.+o   S        |
|B+==.. + .       |
|*BBoo . o        |
|OBOE             |
|X&B+.            |
Enter fullscreen mode Exit fullscreen mode

List your directory to make sure the key files are there. If you

$ ls
# use 'ls ~/.ssh' if you used the default
Enter fullscreen mode Exit fullscreen mode

Your public key file ends in '.pub', the other is your private key.

Next, start the ssh-agent and add your private key to it

$ eval `ssh-agent`
Agent pid 325

# adding private key to ssh-agent
$ ssh-add ./wsl-default
Identity added: ./wsl-default (./wsl-default)
Enter fullscreen mode Exit fullscreen mode

Use cat to show the content of your public key. Copy the content and add a new ssh key to your BitBucket account.

To do this, click on your avatar at the bottom left of the BitBucket dashboard. Then click on 'Bitbucket settings' and then navigate to 'SSH Keys' under the 'Security' section. Go ahead and click 'Add Key'. Give your key a distinct label and paste the contents you copied into the 'Key' section. Hit save.

To confirm that you have correctly configured your Bitbucket for ssh, run the following command on the terminal:

$ ssh -T
Warning: Permanently added the RSA host key for IP address '<ip_address>' to the list of known hosts.
logged in as yamikani
Enter fullscreen mode Exit fullscreen mode

You can go ahead and clone our repository. To do this, open your repository's page in BitBucket and click on 'Clone'. Make sure the dialog reads 'SSH' at the top right corner before you copy the clone command. Copy and paste the command in your terminal and run it.

$ git clone
Cloning into 'my-new-repo'...
remote: Counting objects: 12, done.
remote: Compressing objects: 100% (8/8), done.
remote: Total 12 (delta 1), reused 0 (delta 0)
Receiving objects: 100% (12/12), done.
Resolving deltas: 100% (1/1), done.
Enter fullscreen mode Exit fullscreen mode

And there we have it.

Top comments (1)

jensim profile image
Jens • Edited

If you wanna clone a bitbucket server (all repos on it), I've made a tool for that 😉