Skip to content
Snippets Groups Projects
Verified Commit 9081524c authored by Varac's avatar Varac
Browse files

Use ssh-add to circumvent broken line endings

parent 01a398fd
No related branches found
No related tags found
No related merge requests found
Pipeline #
...@@ -84,11 +84,14 @@ ssh_setup() { ...@@ -84,11 +84,14 @@ ssh_setup() {
SSH_PRIVATE_KEY=${!CI_SSH_SECRET_PRIVATE_KEY} SSH_PRIVATE_KEY=${!CI_SSH_SECRET_PRIVATE_KEY}
echo "Working with provider: $provider_name" echo "Working with provider: $provider_name"
[ -z "$SSH_PRIVATE_KEY" ] && fail "${provider_name}_PROVIDER_SSH_PRIVATE_KEY is not set - please provide it as env variable." [ -z "$SSH_PRIVATE_KEY" ] && fail "${provider_name}_PROVIDER_SSH_PRIVATE_KEY is not set - please provide it as env variable."
# Configure ssh keypair # install ssh-agent
[ -d ~/.ssh ] || /bin/mkdir ~/.ssh which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )
/bin/echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa # run ssh-agent
/bin/chmod 600 ~/.ssh/id_rsa eval $(ssh-agent -s)
/bin/cp "${ROOTDIR}/provider/users/gitlab-runner-${provider_name}/gitlab-runner-${provider_name}_ssh.pub" ~/.ssh/id_rsa.pub # add ssh key stored in SSH_PRIVATE_KEY variable to the agent store
# see https://gitlab.com/gitlab-org/gitlab-ee/issues/2940 for fixing
# broken line endings
ssh-add <(echo "$SSH_PRIVATE_KEY" | sed 's/\r$//')
} }
build_from_scratch() { build_from_scratch() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment