# Clone private bitbucket repository

**URL:** <https://drone.discourse.group/t/clone-private-bitbucket-repository/10077>\
**Category:** Drone Support\
**Created:** [April 23, 2018, 5:29pm UTC](https://drone.discourse.group/t/clone-private-bitbucket-repository/10077 "2018-04-23T17:29:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bolshakov](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/bolshakov/32/4990_2.png) [@bolshakov](https://drone.discourse.group/u/bolshakov)\
**Post date:** [April 23, 2018, 5:29pm UTC](https://drone.discourse.group/t/clone-private-bitbucket-repository/10077/1 "2018-04-23T17:29:24Z")

</div>

I’ve read a bunch of guides about cloning from private repo ([this one](https://stackoverflow.com/questions/41330947/how-to-create-a-drone-secret-file) for example) and still could not understand how it’s supposed to work:

```auto
 commands:
    - mkdir /root/.ssh && echo "$SSH_KEY" > /root/.ssh/id_rsa && chmod 0600 /root/.ssh/id_rsa

```

This step makes no sense for me since I have to pull repository before running commands, so my build fails on cloning stage. Probably this guide is outdated?

---

<div class="post-metadata">

**Author:** ![bradrydzewski](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/bradrydzewski/32/3513_2.png) [@bradrydzewski](https://drone.discourse.group/u/bradrydzewski)\
**Post date:** [April 23, 2018, 5:40pm UTC](https://drone.discourse.group/t/clone-private-bitbucket-repository/10077/2 "2018-04-23T17:40:12Z")

</div>

> This step makes no sense for me since I have to pull repository before running commands, so my build fails on cloning stage. Probably this guide is outdated?

Drone automatically clones your repository. No additional steps or configuration is required. The example you pasted above is for cloning **additional** repositories.

---

<div class="post-metadata">

**Author:** ![bolshakov](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/bolshakov/32/4990_2.png) [@bolshakov](https://drone.discourse.group/u/bolshakov)\
**Post date:** [April 24, 2018, 8:11am UTC](https://drone.discourse.group/t/clone-private-bitbucket-repository/10077/3 "2018-04-24T08:11:52Z")

</div>

It looks like my agent failed to clone private repository:

```auto
+ git init
Initialized empty Git repository in /drone/src/bitbucket.org/org_name/repo_name/.git/
+ git remote add origin https://bitbucket.org/org_name/repo_name.git
+ git fetch --no-tags origin +refs/heads/feature/ci-build:
fatal: unable to access 'https://bitbucket.org/org_name/repo_name.git/': Could not resolve host: bitbucket.org
exit status 128

```

I tried to curl [bitbucket.org](http://bitbucket.org) from agent and it’s reachable:

```auto
> docker exec drone_ci_drone-agent-1_1 apk --no-cache add curl && curl -I https://bitbucket.org |grep HTTP
HTTP/1.1 200 OK

```

How can I debug this issue?

---

<div class="post-metadata">

**Author:** ![bradrydzewski](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/bradrydzewski/32/3513_2.png) [@bradrydzewski](https://drone.discourse.group/u/bradrydzewski)\
**Post date:** [April 24, 2018, 3:52pm UTC](https://drone.discourse.group/t/clone-private-bitbucket-repository/10077/4 "2018-04-24T15:52:38Z")

</div>

> [@On another topic](https://drone.discourse.group/t/2145/3):
>
> Could not resolve host

Please search for “Could not resolve host” in the issue tracker.
