# How Does Cloning Private HTTPS Repo's Work?

**URL:** <https://drone.discourse.group/t/how-does-cloning-private-https-repos-work/9192>\
**Category:** Drone Support\
**Created:** [April 17, 2018, 9:16pm UTC](https://drone.discourse.group/t/how-does-cloning-private-https-repos-work/9192 "2018-04-17T21:16:32Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![donatj](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/donatj/32/5621_2.png) [@donatj](https://drone.discourse.group/u/donatj)\
**Post date:** [April 17, 2018, 9:16pm UTC](https://drone.discourse.group/t/how-does-cloning-private-https-repos-work/9192/1 "2018-04-17T21:16:32Z")

</div>

I am able to clone private repo’s via HTTPs in Drone without providing authentication. It is working well.

I am hoping to understand by what mechanism this works.

I’ve ran `printenv` looking for some sort of environment variable `git` might be picking up and found nothing?

I’ve checked `git config --list` as well as globally and found nothing.

How does this work? Is there some sort of custom git command? Are you hijacking my network traffic? Or is there something else at play?

I’m really curious to understand how this works!

---

<div class="post-metadata">

**Author:** ![jhernandez](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/jhernandez/32/4244_2.png) [@jhernandez](https://drone.discourse.group/u/jhernandez)\
**Post date:** [April 18, 2018, 5:42am UTC](https://drone.discourse.group/t/how-does-cloning-private-https-repos-work/9192/2 "2018-04-18T05:42:54Z")

</div>

drone injects a [.netrc](https://www.gnu.org/software/inetutils/manual/html_node/The-_002enetrc-file.html) file into the container which is what git (more precisely curl) uses.  
if you `cat ~/.netrc` (do not remember the exact location )  
you should see something like this

```auto
machine git.server.com
login x-token-auth
password thetoken 

```

---

<div class="post-metadata">

**Author:** ![donatj](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/donatj/32/5621_2.png) [@donatj](https://drone.discourse.group/u/donatj)\
**Post date:** [April 18, 2018, 3:50pm UTC](https://drone.discourse.group/t/how-does-cloning-private-https-repos-work/9192/3 "2018-04-18T15:50:56Z")

</div>

Awesome! That even works for me on my local machine. I am so pleased to know how this works.

The format however is just a pinch different

```
machine github.com
login {token}
password x-oauth-basic
```

---

<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 18, 2018, 4:18pm UTC](https://drone.discourse.group/t/how-does-cloning-private-https-repos-work/9192/4 "2018-04-18T16:18:54Z")

</div>

Also note that the exact login and password values are vendor-specific

gitlab:

```auto
machine gitlab.com
login oauth2
password {token}

```

github / gogs / gitea:

```auto
machine github.com
login {token}
password x-oauth-basic

```

bitbucket

```auto
machine bitbucket.org
login x-token-auth
password {token}

```

---

<div class="post-metadata">

**Author:** ![zapman449](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/zapman449/32/5988_2.png) [@zapman449](https://drone.discourse.group/u/zapman449)\
**Post date:** [December 28, 2018, 4:27pm UTC](https://drone.discourse.group/t/how-does-cloning-private-https-repos-work/9192/5 "2018-12-28T16:27:58Z")

</div>

Dumb question: How do I CHANGE the token injected here?

(engineer who setup drone left the company. Every setting I can find in Drone points to the github enterprise service account which should do this. But SOMETHING is magically tied to their github enterprise user, and I’m trying to find/change/override it so our CI/CD system works again)

---

<div class="post-metadata">

**Author:** ![jsussman](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/jsussman/32/5244_2.png) [@jsussman](https://drone.discourse.group/u/jsussman)\
**Post date:** [December 28, 2018, 6:04pm UTC](https://drone.discourse.group/t/how-does-cloning-private-https-repos-work/9192/6 "2018-12-28T18:04:32Z")

</div>

You likely need to [chown](https://docs.drone.io/cli/drone-repo-chown/) the non functional repositories to recreate the drone webhooks under a valid user.

---

<div class="post-metadata">

**Author:** ![zapman449](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/zapman449/32/5988_2.png) [@zapman449](https://drone.discourse.group/u/zapman449)\
**Post date:** [December 28, 2018, 8:31pm UTC](https://drone.discourse.group/t/how-does-cloning-private-https-repos-work/9192/7 "2018-12-28T20:31:25Z")

</div>

Thank you! I’ve been beating my head on this for a week…

For future reference, the major symptom we saw was “Your account has been suspended” in the drone server logs (docker logs) after the account was suspended.

---

<div class="post-metadata">

**Author:** ![andrewmclagan](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/andrewmclagan/32/5283_2.png) [@andrewmclagan](https://drone.discourse.group/u/andrewmclagan)\
**Post date:** [May 12, 2020, 4:49am UTC](https://drone.discourse.group/t/how-does-cloning-private-https-repos-work/9192/8 "2020-05-12T04:49:39Z")

</div>

Hmm I simply cannot find where this is injected…! It’s not documented anywhere, we are working with a custom Alpine docker plugin. Attempting to clone a private repo using the same credentials that we assume are inside `.netrc`? But cant find it inside the plugin container.

---

<div class="post-metadata">

**Author:** ![thombou](https://avatars.discourse-cdn.com/v4/letter/t/f1d935/32.png) [@thombou](https://drone.discourse.group/u/thombou)\
**Post date:** [July 15, 2020, 7:15am UTC](https://drone.discourse.group/t/how-does-cloning-private-https-repos-work/9192/9 "2020-07-15T07:15:46Z")

</div>

@andrewmclagan I have the same problem. Did you find a solution to your problem?
