Sign inSign up

adclick/ssh-agent

By adclick

•Updated about 9 years ago

Allow to use private keys inside of containers

Image
0

372

adclick/ssh-agent repository overview

⁠Docker SSH Agent

This image provides an SSH agent. This is useful for sharing SSH identities between the host and running containers.

Docker Hub: https://hub.docker.com/r/adclick/ssh-agent/⁠

⁠Usage

⁠Starting the agent container

Just choose a name for the container and start it.

$> docker run -d --name my-ssh-agent adclick/ssh-agent:latest
⁠Adding your SSH keys

Locate the private key you want to add, mount it in a volume and connect to the agent.

$> docker run --rm -it --volumes-from my-ssh-agent -v /path/to/my/private/key:/ssh-conf/id_rsa adclick/ssh-agent:latest ssh-add /ssh-conf/id_rsa
⁠Using it

Mount the agent's volumes (the socket) and define the SSH_AUTH_SOCK environment variable (with /ssh/socket).

$> docker run --volumes-from my-ssh-agent -e SSH_AUTH_SOCK=/ssh/socket my-fancy-image
⁠User permissions

Sometimes you'll be running containers with users other than root (to avoid permission issues, for example). As the SSH socket can only be accessed by the user that created it, it is necessary to start the agent with that user. This can be achieved by mapping the agent's default user's UID to match your own.

docker run --volumes-from my-ssh-agent -e SSH_AUTH_SOCK=/ssh/socket -e USER_ID=$(id -u) my-fancy-image

Tag summary

Content type

Image

Digest

Size

4.8 MB

Last updated

about 9 years ago

docker pull adclick/ssh-agent