easyscript
easyscript

Reputation: 181

Gitlab CI/CD ssh add return enter passphrase

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.

Upvotes: 10

Views: 8146

Answers (2)

wmandai
wmandai

Reputation: 304

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

Upvotes: 5

Sakura Kinomoto
Sakura Kinomoto

Reputation: 1884

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

Upvotes: 3

Related Questions