Problem with ssh key and new lines Generate your ssh private key with base64 encoding $ cat my_private_key | base64 -w 0 Use the encoded version as Gitlab CI env variable and decode like so: $ ssh-add <(echo "$SSH_PRIVATE_KEY" | base64 -d)