SSH agent docker container image.
Variable | Default Value |
---|---|
Server | |
SOCKET_DIR |
/.ssh-agent |
SSH_AUTH_SOCK |
/.ssh-agent/socket |
SSH_AUTH_PROXY_SOCK |
/.ssh-agent/proxy-socket |
SSH_DIR |
/.ssh |
SSH_KEYS_DIR |
/.ssh-keys |
docker run \
-d \
--name=sshagent \
liip/ssh-agent:1.0.0
Replace SSH_DIR
and KEY
accordingly. If the key has a passphrase, you will be prompted to enter it.
SSH_DIR=~/.ssh
KEY=id_rsa
docker run \
--rm \
--volumes-from=sshagent \
-v ${SSH_DIR}/${KEY}:/.ssh/${KEY} \
-it \
sshagent \
ssh-key add ${KEY}
Replace KEY
accordingly.
KEY=id_rsa
docker run \
--rm \
--volumes-from=sshagent \
-it \
sshagent \
ssh-key remove ${KEY}
docker run \
--rm \
--volumes-from=sshagent \
-it \
sshagent \
ssh-key remove-all
docker run \
--rm \
--volumes-from=sshagent \
-it \
sshagent \
ssh-key list
docker run \
--rm \
--volumes-from=sshagent \
-e SSH_AUTH_SOCK=/.ssh-agent/proxy-socket
-it \
<image> ssh-add -l
COMPOSE_COMPOSE_PROJECT_NAME=sshagent
version: '3.5'
services:
agent:
image: liip/ssh-agent:1.0.0
restart: unless-stopped
volumes:
- socket_dir:/.ssh-agent
- ssh_keys_dir:/.ssh-keys
add:
image: liip/ssh-agent:1.0.0
depends_on:
- agent
command:
- ssh-add
environment:
SSH_AUTH_SOCK: /.ssh-agent/proxy-socket
volumes:
- socket_dir:/.ssh-agent
- ssh_keys_dir:/.ssh-keys
volumes:
socket_dir:
ssh_keys_dir:
Replace SSH_DIR
and KEY
accordingly. If the key has a passphrase, you will be prompted to enter it.
SSH_DIR=~/.ssh
KEY=id_rsa
docker run \
--rm \
--volumes-from=sshagent_agent \
-v ${SSH_DIR}/${KEY}:/.ssh/${KEY} \
-it \
liip/ssh-agent:1.0.0 \
ssh-key add ${KEY}
Replace KEY
accordingly.
KEY=id_rsa
docker run \
--rm \
--volumes-from=sshagent_agent \
-it \
liip/ssh-agent:1.0.0 \
ssh-key remove ${KEY}
docker run \
--rm \
--volumes-from=sshagent_agent \
-it \
liip/ssh-agent:1.0.0 \
ssh-key remove-all
docker run \
--rm \
--volumes-from=sshagent_agent \
-it \
liip/ssh-agent:1.0.0 \
ssh-key list
services:
service_name:
...
environment:
SSH_AUTH_SOCK: /.ssh-agent/proxy-socket
...
volumes:
- ssh_agent_socket_dir:/.ssh-agent
...
volumes:
ssh_agent_socket_dir:
external: true