Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Getting 403 in pipeline (build inside Docker container) when accessing my private repo.

Arkady B November 8, 2018

Hi,

 

I am trying to run atlassian pipeline with my private repo. Having created Dockerfile like this:

FROM golang:1.11
RUN mkdir /root/.ssh/
ADD bitbucket.org /root/.ssh/id_rsa

RUN
touch /root/.ssh/known_hosts
RUN ssh-keyscan bitbucket.org >> /root/.ssh/known_hosts

RUN
git config --global url.ssh://git@bitbucket.org/.insteadOf https://bitbucket.org/

COPY
. /build
WORKDIR /build

RUN
make build

Where bitbucket.org is the private SSH cert with the public key added in to the repo keys section. "make build" command does go app build with go modules on.

During the go modules downalod im getting 403 error as soon as go tries to access my private repo.

This docker build works just fine on local machine with ordinal docker build command.

Response is:

https://api.bitbucket.org/2.0/repositories/arkadyb/myrepo?fields=scm: 403 Forbidden

What am i doing wrong?

 

1 answer

2 votes
Arkady B November 8, 2018

Was able to find solution.

 

This Docker file works both Atlassian Pipeline and local machine:

FROM golang:1.11

RUN mkdir /root/.ssh/
ADD bitbucket.org /root/.ssh/id_rsa
RUN chmod 400 /root/.ssh/id_rsa

RUN touch /root/.ssh/known_hosts
RUN ssh-keyscan bitbucket.org >> /root/.ssh/known_hosts
RUN git ls-remote git@bitbucket.org:[myusername]/[myprivatereponame].git
RUN git config --global url.ssh://git@bitbucket.org/.insteadOf https://bitbucket.org/

COPY
. /build
WORKDIR /build

RUN make build

 

Ofcouse the public key is added in to the access keys section of given private repo.

vboulytchev October 6, 2019

I've tried this:

 

```

RUN mkdir /root/.ssh/
ADD serviceBitbucketKey.ssh /root/.ssh/id_rsa
RUN chmod 400 /root/.ssh/id_rsa

RUN touch /root/.ssh/known_hosts
RUN ssh-keyscan bitbucket.org >> /root/.ssh/known_hosts
RUN git ls-remote git@bitbucket.org:orgName/repo.git
RUN git config --global url.ssh://git@bitbucket.org/.insteadOf https://bitbucket.org/

```

But fails with:

```
Load key "/root/.ssh/id_rsa": invalid format
```

The `serviceBitbucketKey.ssh` was generated with:
```

ssh-keygen -t rsa -b 4096 -f serviceBitbucketKey.ssh

```

Any suggestions?

vboulytchev October 8, 2019

the `serviceBitbucketKey.ssh`'s pub record is added to bitbucket.

I have a feeling that the actual key generation is the problem here...

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events