The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

Articles
Create
cancel
Showing results forĀ 
Search instead forĀ 
Did you mean:Ā 

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

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

0 votes
Answer accepted
Kshitij Pandey
December 11, 2019

I generated new SSH keys and that fixed my problem!

TAGS
AUG Leaders

Atlassian Community Events