Name: docker-ssh-env-config
Owner: Buildkite
Description: Sets up SSH config files within a container based on environment variables
Created: 2015-10-26 03:10:05.0
Updated: 2018-03-20 10:13:42.0
Pushed: 2016-02-25 06:51:01.0
Homepage: null
Size: 8
Language: Shell
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
A Docker entrypoint wrapper which sets up SSH config files based on the following environment variables:
SSH_CONFIG
- contents of an SSH config fileSSH_KNOWN_HOSTS
- contents of an SSH known_hosts fileSSH_PRIVATE_RSA_KEY
- contents of an SSH private RSA keySSH_PRIVATE_DSA_KEY
- contents of an SSH private DSA keySSH_DEBUG
- enables SSH debug loggingYou can also provide base64 encoded versions by adding _B64
to the end of the environment variable (e.g. SSH_PRIVATE_RSA_KEY_B64
, useful for environments that don't support newlines) and _PATH
for specifying a file to get the contents from (e.g. SSH_PRIVATE_RSA_KEY_PATH
, useful for secret stores mounted as volumes).
Things to keep in mind:
~/.ssh
will be overwritten with these new valuesAfter adding it to the Dockerfile:
u should use a commit hash rather than "master" in your own version of the below
curl -fL "https://raw.githubusercontent.com/buildkite/docker-ssh-env-config/master/ssh-env-config.sh" -o /usr/local/bin/ssh-env-config.sh \
&& chmod +x /usr/local/bin/ssh-env-config.sh \
YPOINT ["ssh-env-config.sh","some-command"]
You can then configure SSH via environment variables:
er run -e SSH_KNOWN_HOSTS="$(< ~/.ssh/known_hosts)" ...
Or you can pass in the base64 encoded version by appending _B64
:
er run -e SSH_KNOWN_HOSTS_B64="$(base64 < ~/.ssh/known_hosts)" ...
Or you can pass a path to a file with the contents by appending _PATH
:
er run -e SSH_KNOWN_HOSTS_PATH="/mnt/secrets/known-hosts" ...
sts.sh || echo "Boo, tests failed."