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/phusion/passenger-docker with boot2docker on Yosemite.
ssh-add -l ...key details boot2docker up
Then I use the command which I have seen in a number of places (i.e. https://gist.github.com/d11wtq/8699521):
docker run --rm -t -i -v $SSH_AUTH_SOCK:/ssh-agent -e SSH_AUTH_SOCK=/ssh-agent my_image /bin/bash
However it doesn't seem to work:
root@299212f6fee3:/# ssh-add -l Could not open a connection to your authentication agent. root@299212f6fee3:/# eval `ssh-agent -s` Agent pid 19 root@299212f6fee3:/# ssh-add -l The agent has no identities. root@299212f6fee3:/# ssh [email protected] Warning: Permanently added the RSA host key for IP address '192.30.252.128' to the list of known hosts. Permission denied (publickey).
The ssh-agent is a helper program that keeps track of user's identity keys and their passphrases. The agent can then use the keys to log into other servers without having the user type in a password or passphrase again. This implements a form of single sign-on (SSO).
Double-click Docker.dmg to open the installer, then drag the Docker icon to the Applications folder. Double-click Docker.app in the Applications folder to start Docker.
Currently, to use Docker on Mac and Windows requires the use of Docker Toolbox. You have to download it, install a bunch of tools and dependencies for it to work. And since Docker uses Linux-specific tools you can't run it natively. Instead, you have to use docker-machine and attach to a VirtualBox VM on your system.
Since version 2.2.0.0
, docker for macOS allows users to access the host’s SSH agent inside containers.
Here's an example command that let's you do it:
docker run --rm -it \ -v /run/host-services/ssh-auth.sock:/ssh-agent \ -e SSH_AUTH_SOCK="/ssh-agent" \ my_image
Note that you have to mount the specific path (/run/host-services/ssh-auth.sock
) instead of the path contained in $SSH_AUTH_SOCK
environment variable, like you would do on linux hosts.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With