Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gitlab CI/CD ssh add return enter passphrase

Tags:

ssh

gitlab

When triggered, pipeline runs and return the following error,

$ ssh-add <(echo "$SSH_PRIVATE_KEY")
Enter passphrase for /dev/fd/63: ERROR: Job failed: exit code 1

my SSH_PRIVATE_KEY variable exist with a valid private key.

like image 998
easyscript Avatar asked Dec 04 '18 05:12

easyscript


2 Answers

In my case, I had set the SSH_PRIVATE_KEY variable to "protected", so this worked when building from a protected branch. If your SSH_PRIVATE_KEY variable is Protected ensure your branch is also protected. Information on how to protect your gitlab branch

like image 50
William Mandai Avatar answered Oct 24 '22 02:10

William Mandai


There's two possible options to achieve it.

First option: Use another SSH private key who didn't request to enter a passphrase.

Second option: Use a expect syntax to "interactively" enter passphrase when it required [1].

Don't think the second option is more secure than first one, because, on the shell file you need to store your passphrase without any encryption.

[1] https://unix.stackexchange.com/questions/288099/how-to-write-expect-in-shell

like image 3
Sakura Kinomoto Avatar answered Oct 24 '22 03:10

Sakura Kinomoto