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

Docker build pipeline fails with Permission denied (publickey).

Kshitij Pandey December 11, 2019

I have a pipeline set up which builds and pushes Docker image to my ECR. This Dockerfile runs npm install to install a few private repositories in my account for which I have set up the SSH keys to get access to those private repositories. When I run the build command on my local machine the build works perfectly but it breaks when I run the pipeline giving me the error `Permission denied (publickey).npm ERR! fatal: Could not read from remote repository.`

RUN mkdir /root/.ssh/
RUN chmod 700 /root/.ssh
# Add the keys and set permissions
COPY ./ssh/. /root/.ssh/
RUN chmod 600 /root/.ssh/id_rsa
# Add bitbuckets key
RUN touch /root/.ssh/config && echo "Host bitbucket.org\n\tHostName bitbucket.org\n\tIdentityFile /root/.ssh/id_rsa" > /root/.ssh/config
RUN ssh-keyscan -H bitbucket.org >> /root/.ssh/known_hosts

The npm install works perfectly if I run them locally or with the Docker build command but fails when I run the pipeline. Any suggestions?

1 answer

1 accepted

0 votes
Answer accepted
Kshitij Pandey December 11, 2019

I generated new SSH keys and that fixed my problem!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events