I am trying to clone a git repository using ssh in a docker image and i want to do this while building the dockerfile. I can make this work using git clone https with username and password, but using ssh, it fails. My dockerfile looks like
# Install software
RUN apt-get install -y git
# Make ssh dir
RUN mkdir -p /${APP_USER}/.ssh/
RUN apt-get update
RUN apt-get -qq -y install curl
RUN apt-get -qq -y install \
openssh-client openssh-server
ADD id_rsa /${APP_USER}/.ssh/id_rsa
# Create known_hosts
RUN touch /${APP_USER}/.ssh/known_hosts
# Add bitbuckets key
RUN ssh-keyscan bitbucket.org >> /${APP_USER}/.ssh/known_hosts
# Pull the master branch
RUN cd ${HOME} \
&& git clone ssh://git@bitbucket.services...... \
&& ls -la
I have added steps to install git, copied the private ssh key to the user folder, placed the public key in bitbucket repo, added known hosts but still i get the following error
Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.