Fixing 'Enter passphrase for /dev/fd/63' in a Gitlab CI job
By: +David Herron; Date: 2016-06-30 16:53
The official example for using an SSH key in a
.gitlab-ci.yml file is here:- https://gitlab.com/gitlab-examples/ssh-private-key/blob/master/.gitlab-ci.yml
The instructions are to ensure
ssh-agent is installed, then to run
eval $(ssh-agent -s) ssh-add <(echo "$SSH_PRIVATE_KEY")
The Enter passphrase for /dev/fd/63 message occurred right after that last command. The message is cryptic, however the
ssh-add command for some reason thinks it must ask for a passphrase. For example, is it an
ssh key which requires a secondary password?
What we have to do is revisit the process of attaching an SSH key to a Gitlab CI configuration.
The first step is to generate an SSH key that you'll use for this Gitlab CI job. On your laptop you do have OpenSSH tools installed, and have access to the
ssh-keygen command, right?
$ ssh-keygen -f ~/Downloads/hmp.key
Just hit return for all the prompts. Give whatever filename you wish - that was simply the one I used. It generates the private key in the named file, then generates a second file containing the public key. In my case that file name was
It's important that this ssh key not have a passphrase associated with it. That's why it's important to just hit return for all the prompts. It's important that, for this key, that SSH tools not prompt for a passphrase.
In Gitlab, go to the
Variables section of the project configuration. Add a new Variable, named
SSH_PRIVATE_KEY, whose contents is the text in the private key file just generated.
Then, on any server this Gitlab CI job needs to access, add the public key. For example, add it to
~/.ssh/authorized_keys on the server.
Once you've done these steps, the
ssh-add shown above will execute properly.