从Dockerfile克隆私有git存储库

oneor0

我的目标是从Dockerfile克隆私有存储库。我复制了我的私人SSH密钥,然后将bitbucket.org域添加到known_hosts文件中,但是当我尝试克隆存储库时,由于某种原因,我会收到“权限被拒绝”错误。我可以从主机上克隆此存储库。我想念什么?

Dockerfile:

FROM ubuntu

RUN apt-get update
RUN apt-get install -y git ssh

ARG SSH_PRIVATE_KEY
RUN mkdir /root/.ssh/
RUN echo "${SSH_PRIVATE_KEY}" > /root/.ssh/id_rsa
RUN chmod 600 /root/.ssh/id_rsa

RUN touch /root/.ssh/known_hosts
RUN ssh-keyscan bitbucket.org >> /root/.ssh/known_hosts

RUN git clone [email protected]:foo/bar.git

命令:

docker build --build-arg SSH_PRIVATE_KEY="$(cat ~/.ssh/id_rsa)" .

输出:

Warning: Permanently added the RSA host key for IP address '18.205.93.2' to the list of known hosts.
[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

运行ssh -v [email protected]输出:

OpenSSH_7.6p1 Ubuntu-4ubuntu0.3, OpenSSL 1.0.2n  7 Dec 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
Pseudo-terminal will not be allocated because stdin is not a terminal.
debug1: Connecting to bitbucket.org [18.205.93.0] port 22.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_rsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ed25519-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.6p1 Ubuntu-4ubuntu0.3
debug1: Remote protocol version 2.0, remote software version conker_b9a79bcd5e-dirty conker-3002
debug1: no match: conker_b9a79bdd5e-dirty conker-3002
debug1: Authenticating to bitbucket.org:22 as 'git'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: [email protected]
debug1: kex: host key algorithm: ssh-rsa
debug1: kex: server->client cipher: [email protected] MAC: <implicit> compression: none
debug1: kex: client->server cipher: [email protected] MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ssh-rsa SHA256:zzXQOXSRBEiUtuEwbHaxvSc0ojez6sdf6s9YXaGp1A
debug1: Host 'bitbucket.org' is known and matches the RSA host key.
debug1: Found key in /root/.ssh/known_hosts:1
Warning: Permanently added the RSA host key for IP address '18.205.93.0' to the list of known hosts.
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /root/.ssh/id_rsa
debug1: read_passphrase: can't open /dev/tty: No such device or address
debug1: Trying private key: /root/.ssh/id_dsa
debug1: Trying private key: /root/.ssh/id_ecdsa
debug1: Trying private key: /root/.ssh/id_ed25519
debug1: No more authentication methods to try.
[email protected]: Permission denied (publickey).
克里斯·梅斯

您需要确保正确填充了id_rsa:

docker build --build-arg SSH_PRIVATE_KEY="$(cat ~/.ssh/id_rsa)" .

编辑此功能仅适用于无密码的密钥,否则情况会变得复杂。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

git在分叉私有存储库后无法克隆

来自分类Dev

git在分叉私有存储库后无法克隆

来自分类Dev

使GitLab CI克隆私有存储库

来自分类Dev

如何使用初始化Shell脚本克隆私有Git存储库

来自分类Dev

如何使用初始化Shell脚本克隆私有Git存储库

来自分类Dev

如何在nix派生中克隆私有git存储库

来自分类Dev

克隆没有证书的私有github存储库?

来自分类Dev

docker构建在包含Dockerfile的私有git存储库上?

来自分类Dev

是否可以在Dockerfile ADD中使用私有git(hub)存储库?

来自分类Dev

docker是否在包含Dockerfile的私有git存储库上构建?

来自分类Dev

使用脚本克隆私有Github存储库

来自分类Dev

如何克隆私有的GitLab存储库?

来自分类Dev

从另一个存储库分支克隆后,推送到私有存储库

来自分类Dev

Git克隆已经是克隆的存储库

来自分类Dev

克隆git存储库的问题

来自分类Dev

无法克隆Git存储库

来自分类Dev

使用HTTPS Git访问私有存储库

来自分类Dev

在git中的远程存储库上创建私有分支

来自分类Dev

捆绑安装-不带私有git存储库的<group>

来自分类Dev

使用HTTPS Git访问私有存储库

来自分类Dev

将克隆的TFS存储库推送到具有历史记录的私有存储库

来自分类Dev

私有存储库的私有派生

来自分类Dev

如何在GitHub桌面应用程序中克隆私有BitBucket存储库

来自分类Dev

允许非GitHub用户通过密码克隆私有存储库

来自分类Dev

可以从私有GitHub存储库中克隆和提取,但不能提取

来自分类Dev

如何在Jenkins Job中克隆github组织的私有存储库

来自分类Dev

使用Apache和mod_macro设置私有多个公共/私有Git存储库

来自分类Dev

GIT 并行克隆所有存储库,即克隆所有存储库所需的总时间接近最大存储库所需的时间:fatal: index-pack failed

来自分类Dev

Bitbucket克隆私人git存储库

Related 相关文章

  1. 1

    git在分叉私有存储库后无法克隆

  2. 2

    git在分叉私有存储库后无法克隆

  3. 3

    使GitLab CI克隆私有存储库

  4. 4

    如何使用初始化Shell脚本克隆私有Git存储库

  5. 5

    如何使用初始化Shell脚本克隆私有Git存储库

  6. 6

    如何在nix派生中克隆私有git存储库

  7. 7

    克隆没有证书的私有github存储库?

  8. 8

    docker构建在包含Dockerfile的私有git存储库上?

  9. 9

    是否可以在Dockerfile ADD中使用私有git(hub)存储库?

  10. 10

    docker是否在包含Dockerfile的私有git存储库上构建?

  11. 11

    使用脚本克隆私有Github存储库

  12. 12

    如何克隆私有的GitLab存储库?

  13. 13

    从另一个存储库分支克隆后,推送到私有存储库

  14. 14

    Git克隆已经是克隆的存储库

  15. 15

    克隆git存储库的问题

  16. 16

    无法克隆Git存储库

  17. 17

    使用HTTPS Git访问私有存储库

  18. 18

    在git中的远程存储库上创建私有分支

  19. 19

    捆绑安装-不带私有git存储库的<group>

  20. 20

    使用HTTPS Git访问私有存储库

  21. 21

    将克隆的TFS存储库推送到具有历史记录的私有存储库

  22. 22

    私有存储库的私有派生

  23. 23

    如何在GitHub桌面应用程序中克隆私有BitBucket存储库

  24. 24

    允许非GitHub用户通过密码克隆私有存储库

  25. 25

    可以从私有GitHub存储库中克隆和提取,但不能提取

  26. 26

    如何在Jenkins Job中克隆github组织的私有存储库

  27. 27

    使用Apache和mod_macro设置私有多个公共/私有Git存储库

  28. 28

    GIT 并行克隆所有存储库,即克隆所有存储库所需的总时间接近最大存储库所需的时间:fatal: index-pack failed

  29. 29

    Bitbucket克隆私人git存储库

热门标签

归档