Using ssh-agent with docker on macOS

后端 未结 8 2262
不思量自难忘°
不思量自难忘° 2021-02-02 10:18

I would like to use ssh-agent to forward my keys into the docker image and pull from a private github repo.

I am using a slightly modified version of https://github.com/

8条回答
  •  無奈伤痛
    2021-02-02 10:25

    For me accessing ssh-agent to forward keys worked on OSX Mavericks and docker 1.5 as follows:

    1. ssh into the boot2docker VM with boot2docker ssh -A. Don't forget to use option -A which enables forwarding of the authentication agent connection.

    2. Inside the boot2docker ssh session:

      docker@boot2docker:~$ echo $SSH_AUTH_SOCK
      /tmp/ssh-BRLb99Y69U/agent.7750
      

    This session must be left open. Take note of the value of the SSH_AUTH_SOCK environmental variable.

    1. In another OS X terminal issue the docker run command with the SSH_AUTH_SOCK value from step 2 as follows:

      docker run --rm -t -i \
        -v /tmp/ssh-BRLb99Y69U/agent.7750:/ssh-agent \
        -e SSH_AUTH_SOCK=/ssh-agent my_image /bin/bash
      root@600d0e9b443d:/# ssh-add -l
      2048 6c:8e:82:08:74:33:78:61:f9:9a:74:1b:65:46:be:eb         
      /Users/dev/.ssh/id_rsa (RSA)
      

    I don't really like the fact that I have to keep a boot2docker ssh session open to make this work, but until a better solution is found, this at least worked for me.

提交回复
热议问题