I Could not succeed in Cloning the Private Git Repository in My Docker Container- Azure Pipeline.
Below is My Docker File Content:
RUN apt-get update
RUN sudo apt-get install -y openssh-server openssh-client
# add credentials on build
ARG SSH_PRIVATE_KEY
RUN mkdir /root/.ssh/
RUN echo “${SSH_PRIVATE_KEY}” > ~/.ssh/id_rsa
RUN chmod 0400 ~/.ssh/id_rsa
# make sure your domain is accepted
RUN touch /root/.ssh/known_hosts
RUN ssh-keyscan github.com >> /root/.ssh/known_hosts
RUN git clone git@github.com:Myproject/My_repo.git
Error is below:
Step 17/97 : RUN git clone git@github.com:edcast/guideme_analytics.git
---> Running in 41b8c754d219
Cloning into 'My_repo'...
Warning: Permanently added the ECDSA host key for IP address '20.207.73.82' to the list of known hosts.
Load key "/root/.ssh/id_rsa": invalid format
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
The command '/bin/sh -c git clone git@github.com:Myproject/My_repo.git' returned a non-zero code: 128
##[debug]Exit code 128 received from tool '/usr/bin/docker'
##[debug]STDIO streams have closed for tool '/usr/bin/docker'
##[error]The command '/bin/sh -c git clone git@github.com:Myproject/My_repo.git' returned a non-zero code: 128
##[debug]Processed: ##vso[task.issue type=error;]The command '/bin/sh -c git clone git@github.com:Myproject/My_repo.git' returned a non-zero code: 128
##[debug]task result: Failed
##[error]The process '/usr/bin/docker' failed with exit code 128