Created
August 6, 2018 18:34
-
-
Save webyneter/a727ef1c00ccddfb52b34a100f6f78a4 to your computer and use it in GitHub Desktop.
SSH from GitLab CI runner
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
#!/usr/bin/env bash | |
### Source: | |
### https://gist.github.com/yannhowe/5ab1501156bd84c8ac261e2c17b8e3e0#gistcomment-2564991 | |
mkdir -p ~/.ssh | |
# https://docs.gitlab.com/ee/ci/ssh_keys/#how-it-works | |
echo "${CI_RUNNER_SSH_PRIVATE_KEY}" | tr -d '\r' > ~/.ssh/id_rsa | |
chmod 700 ~/.ssh/id_rsa | |
eval "$(ssh-agent -s)" | |
ssh-add ~/.ssh/id_rsa | |
# https://docs.gitlab.com/ee/ci/ssh_keys/#verifying-the-ssh-host-keys | |
ssh-keyscan -H 'gitlab.com' >> ~/.ssh/known_hosts |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment