SSH Key usage example for docker images seems to have a faulty command
We followed the instructions for SSH key usage within a docker image (https://docs.gitlab.com/ee/ci/ssh_keys/#ssh-keys-when-using-the-docker-executor) but consistently ran into a problem with the ssh-add command. We had (and verified outside of gitlab) passwordless key setup for SSH but when we used the code exactly as is in the example, it failed on ssh-add asking for a passphrase (snippet from the build log):
$ command -v ssh-agent >/dev/null || ( apt-get update -y && apt-get install openssh-client -y ) # collapsed multi-line command
Agent pid 1755
Enter passphrase for /builds/xxxxx/xxxx/xxx/xxxx/xxxxx.tmp/SSH_PRIVATE_KEY
We had to work around it with this (along with changing the type of the variable from file back to variable):
command -v ssh-agent >/dev/null || ( apt-get update -y && apt-get install openssh-client -y )
eval $(ssh-agent -s)
mkdir -p ~/.ssh
chmod 700 ~/.ssh
echo "$SSH_PRIVATE_KEY" | tr -d '\r' | DISPLAY=None SSH_ASKPASS=~/.ssh/tmp ssh-add -