Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error loading key "(stdin)": invalid format Gitlab CI

This is piece of my yaml file about ssh for gitlab ci:

eval $(ssh-agent -s)
echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
mkdir -p ~/.ssh
chmod 700 ~/.ssh
'[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'

When I attempted to set SSH_PRIVATE_KEY variable to protected state, it occurs error:

Error loading key "(stdin)": invalid format

and I don't know why it's okay when I set SSH_PRIVATE_KEY variable to unprotected state

like image 322
Tomas Shelby Avatar asked Dec 05 '19 14:12

Tomas Shelby


1 Answers

For me it also failed because the SSH_PRIVATE_KEY was marked as "Protected" but the tag I was using was not.

So either make the branch or tag you are using also protected or remove the "Protected" setting from the SSH_PRIVATE_KEY variable.

See: https://gitlab.com/help/ci/variables/README#create-a-custom-variable-in-the-ui

Protect variable (Optional): If selected, the variable will only be available in pipelines that run on protected branches or tags.

like image 61
Arno van Oordt Avatar answered Oct 02 '22 10:10

Arno van Oordt