Created
June 18, 2019 09:20
-
-
Save kurahaupo/6ec05c8d9c94046acf5f16da1fd1775f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
write_key() { | |
mkdir -p "${JENKINS_AGENT_HOME}/.ssh" | |
echo "$1" > "${JENKINS_AGENT_HOME}/.ssh/authorized_keys" | |
chown -Rf jenkins:jenkins "${JENKINS_AGENT_HOME}/.ssh" | |
chmod 0700 -R "${JENKINS_AGENT_HOME}/.ssh" | |
} | |
if [[ $JENKINS_SLAVE_SSH_PUBKEY == ssh-* ]]; then | |
write_key "${JENKINS_SLAVE_SSH_PUBKEY}" | |
fi | |
if [[ $# -gt 0 ]]; then | |
if [[ $1 == ssh-* ]]; then | |
write_key "$1" | |
shift 1 | |
else | |
exec "$@" | |
fi | |
fi | |
# ensure variables passed to docker container are also exposed to ssh sessions | |
env | grep _ >> /etc/environment | |
ssh-keygen -A | |
exec /usr/sbin/sshd -D -e "${@}" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment