GITLAB CI Error loading key "/dev/fd/63": invalid format ERROR: Job failed: exit code 1
This error happens when the private key in $SSH_PRIVATE_KEY is malformed, you can easily test it locally if you add some random characters in it. In particular, it happens on Travis-CI when you just copy & paste the private key into the SSH_PRIVATE_KEY variable in the online form. It has to do with the new line characters after and before the -----BEGIN RSA PRIVATE KEY-----, -----END RSA PRIVATE KEY----- blocks. For this reason, I use base64 encoding to make sure the key is formatted properly.
try this:
Encode your private RSA key
cat my_private_key | base64 -w0
Add the base64 string to your project variables.
- Use it in your .gitlab-ci.yml
ssh-add <(echo "$SSH_PRIVATE_KEY" | base64 -d)
https://gitlab.com/gitlab-examples/ssh-private-key/issues/1#note_15038961
If you have protected the variable then you need to have a protected branch. As mentioned in the variables settings - "They can be protected by only exposing them to protected branches or tags."