Fixing 'Enter passphrase for /dev/fd/63' in a Gitlab CI job

; Date: Thu Jun 30 2016

Tags: Gitlab »»»» SSH Key »»»» Security

If you're a Gitlab user you're probably hoping to use Gitlab CI to automate builds and deployments. You probably want to deploy something using rsync, using an SSH key for security. Unfortunately (in my opinion) the official Gitlab documentation is confusing. While the Gitlab team does provide example .gitlab-ci.yml files that are supposed to work, the actual specifics of what to do are sketchy, and I found myself puzzling over a curious error message: "Enter passphrase for /dev/fd/63" ... WTF?

The official example for using an SSH key in a .gitlab-ci.yml file is here:- (gitlab.com) 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?

Simply run:

$ 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 /Users/david/Downloads/hmp.key.pub.

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.

About the Author(s)

(davidherron.com) David Herron : David Herron is a writer and software engineer focusing on the wise use of technology. He is especially interested in clean energy technologies like solar power, wind power, and electric cars. David worked for nearly 30 years in Silicon Valley on software ranging from electronic mail systems, to video streaming, to the Java programming language, and has published several books on Node.js programming and electric vehicles.