bitbucket docker权限被拒绝(publickey)。 致命的:无法从远程存储库读取

我正在用下面的代码创build一个docker文件:

# Update aptitude with new repo RUN apt-get update # Install software RUN apt-get install -y git # Make ssh dir RUN mkdir /root/.ssh/ # Copy over private key, and set permissions ADD id_rsa /root/.ssh/id_rsa # Create known_hosts RUN touch /root/.ssh/known_hosts # Add bitbuckets key RUN ssh-keyscan bitbucket.org >> /root/.ssh/known_hosts RUN chgrp 545 ~/.ssh/id_rsa RUN chmod 600 ~/.ssh/id_rsa # Clone the conf files into the docker container RUN git clone git@bitbucket.org:xxxxxx/teste.git RUN cd teste echo "# My project's README" >> README.md RUN git add README.md RUN git commit -m "Initial commit" RUN git push -u origin master 

但是当我build立文件时,我得到了以下错误:

克隆到“teste”中警告:将IP地址“xxx.xxx.xxx.x”的RSA主机密钥永久添加到已知主机列表中。 权限被拒绝(publickey)。 致命的:无法从远程存储库读取。

请确保您拥有正确的访问权限并存在存储库。 命令'/ bin / sh -c git clone git@bitbucket.org:xxxxxxxx / teste.git'返回一个非零的代码:128

我使用PuTTY key gen生成了id_rsa,并且已经存储在bitbucket中。

任何人都可以帮忙

我相信你还需要在容器中添加相应的私钥。 由于您提到您使用putty生成了id_rsa密钥,因此密钥在您的主机中。

你需要的是在你的容器中添加id_rsa键,在bitbucket上添加id_rsa.pub。

这篇文章可能会帮助你更多。