3

In gitlab, I made a variable SSH_PRIVATE_KEY with my private key, and try to add it on the fly with

   before_script:
     - ssh-add <(echo "$SSH_PRIVATE_KEY")

I get an error

/bin/sh: eval: line 81: syntax error: unexpected "("

How should I fix it ?

7
  • Why don't you just create a file with the private key, like ssh-add expects?
    – chepner
    Jan 25, 2019 at 16:35
  • I am following this answer stackoverflow.com/a/38570269/1956558
    – Juliatzin
    Jan 25, 2019 at 16:37
  • 3
    The immediate issue is that process substitution (<(...)) isn't supported by the POSIX shell specification, and whatever shell your system is actually using to execute the before-script doesn't either. Likely, your /bin/sh is something like dash rather than bash. You need to find someway to change what shell GitLab uses.
    – chepner
    Jan 25, 2019 at 16:46
  • 1
    Even if /bin/sh is Bash, it'll run in POSIX mode if called as /bin/sh and choke on process substitution. Jan 25, 2019 at 16:51
  • @chepner I am using alpine docker image.
    – Juliatzin
    Jan 25, 2019 at 17:05

1 Answer 1

0

echo "$SSH_PRIVATE_KEY" | ssh-add -

try this

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.