# Running git commands in private repo inside docker not working correctly

**URL:** https://meta.discourse.org/t/running-git-commands-in-private-repo-inside-docker-not-working-correctly/67321
**Category:** Development
**Created:** [August 2, 2017, 1:33pm UTC](https://meta.discourse.org/t/running-git-commands-in-private-repo-inside-docker-not-working-correctly/67321 "2017-08-02T13:33:01Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![net\_deamon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/net_deamon/32/70126_2.png) [@net\_deamon](https://meta.discourse.org/u/net_deamon)
#### Post date: [August 2, 2017, 1:33pm UTC](https://meta.discourse.org/t/running-git-commands-in-private-repo-inside-docker-not-working-correctly/67321/1 "2017-08-02T13:33:01Z")

</div>

I am working on bitbucket support for the docker\_manager plugin. It does not work well with [private repositories](https://meta.discourse.org/t/update-private-plugin-without-rebuilding-the-application/63286/).

The plugin works by running the following commands to check the `commits behind`

**latest\_local\_commit** `git rev-parse --short HEAD` (local repo latest commit)

**latest\_origin\_commit** `git rev-parse --short origin/master` (server repo latest commit)

**commits\_behind** `git rev-list --count HEAD..origin/master` to fetch the difference in number

The problem is that when I run the command of commit\_behind in command line inside docker container plugin repository, I get 0.  
But there are actually some commits made in the bitbucket private repository.  
When I check locally in my machine, I rightly get the commits\_behind number as 2.

I have added the ssh keys in /root/.ssh folder for the bitbucket repo. I am not able to understand why would the git command show 0 inside docker container (incorrect) but 2 in local machine(correct)

---

<div class="post-metadata">

### Author: ![elijah](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/elijah/32/104055_2.png) [@elijah](https://meta.discourse.org/u/elijah)
#### Post date: [August 2, 2017, 3:30pm UTC](https://meta.discourse.org/t/running-git-commands-in-private-repo-inside-docker-not-working-correctly/67321/2 "2017-08-02T15:30:16Z")

</div>

This might be obvious, but have you checked that the ssh directory and files in it have tight permissions? That’s something ssh is picky about, and probably git using ssh, too. Mode 700 on directory, 600 on files is tight.

---

<div class="post-metadata">

### Author: ![net\_deamon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/net_deamon/32/70126_2.png) [@net\_deamon](https://meta.discourse.org/u/net_deamon)
#### Post date: [August 4, 2017, 12:42am UTC](https://meta.discourse.org/t/running-git-commands-in-private-repo-inside-docker-not-working-correctly/67321/3 "2017-08-04T00:42:31Z")

</div>

I changed the .ssh folder to 700 permission, and its contents ( `id_rsa` and `id_rsa.pub` ) to 600.

But still I got 0 when I checked for `commit_behind`.

---

<div class="post-metadata">

### Author: ![elijah](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/elijah/32/104055_2.png) [@elijah](https://meta.discourse.org/u/elijah)
#### Post date: [August 4, 2017, 2:32am UTC](https://meta.discourse.org/t/running-git-commands-in-private-repo-inside-docker-not-working-correctly/67321/4 "2017-08-04T02:32:20Z")

</div>

What happens if you try to ssh to the git repo host from inside your app?

```bash
cd /var/discourse
./launcher enter app
ssh -v user@github.com.or.wherever

```

The last few lines for me look like:

```plaintext
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /root/.ssh/id_rsa
debug1: Authentications that can continue: publickey
debug1: Trying private key: /root/.ssh/id_dsa
debug1: Trying private key: /root/.ssh/id_ecdsa
debug1: Trying private key: /root/.ssh/id_ed25519
debug1: No more authentication methods to try.
Permission denied (publickey).

```

(I created an id\_rsa key for this test, but it isn’t on gitbhub.) Do you see the key being offered?

---

<div class="post-metadata">

### Author: ![net\_deamon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/net_deamon/32/70126_2.png) [@net\_deamon](https://meta.discourse.org/u/net_deamon)
#### Post date: [August 4, 2017, 4:35pm UTC](https://meta.discourse.org/t/running-git-commands-in-private-repo-inside-docker-not-working-correctly/67321/5 "2017-08-04T16:35:55Z")

</div>

I got the key. Here are the logs

```
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /root/.ssh/id_rsa
debug1: Server accepts key: pkalg ssh-rsa blen 279
debug1: Authentication succeeded (publickey).
Authenticated to bitbucket.org ([104.XXX.XXX.1]:22).
debug1: channel 0: new [client-session]
debug1: Entering interactive session.
debug1: pledge: network
debug1: Sending environment.
debug1: Sending env LANG = en_US.UTF-8
PTY allocation request failed on channel 0
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
authenticated via a deploy key.

You can use git or hg to connect to Bitbucket. Shell access is disabled.

```

---

<div class="post-metadata">

### Author: ![elijah](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/elijah/32/104055_2.png) [@elijah](https://meta.discourse.org/u/elijah)
#### Post date: [August 4, 2017, 4:37pm UTC](https://meta.discourse.org/t/running-git-commands-in-private-repo-inside-docker-not-working-correctly/67321/6 "2017-08-04T16:37:50Z")

</div>

Well, it’s not an ssh issue then. I’m not git expert enough to suggest what to try next.

---

<div class="post-metadata">

### Author: ![net\_deamon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/net_deamon/32/70126_2.png) [@net\_deamon](https://meta.discourse.org/u/net_deamon)
#### Post date: [August 4, 2017, 4:38pm UTC](https://meta.discourse.org/t/running-git-commands-in-private-repo-inside-docker-not-working-correctly/67321/7 "2017-08-04T16:38:31Z")

</div>

Thanks anyways for the help 🙂
