Is there a `ssh-add` Linux alpine one liner

2019-04-29 02:01发布

I need during a Gitlab-CI build to authenticate with ssh-agent from an alpine image.

I am looking for a sh one liner equivalent of this bash command (picked from the gitlab documentation):

ssh-add <(echo "$SSH_PRIVATE_KEY")

I have tried :

echo $SSH_PRIVATE_KEY | ssh-add -
Enter passphrase for (stdin): ERROR: Job failed: exit code 1

printf '%s\n' "$SSH_PRIVATE_KEY" | ssh-add
ERROR: Job failed: exit code 1

标签: linux bash ssh sh
1条回答
唯我独甜
2楼-- · 2019-04-29 02:57

You have to quote the variable in your first command:

echo "$SSH_PRIVATE_KEY" | ssh-add -
     ^----------------^

Or specify - as the filename in your second command:

printf '%s\n' "$SSH_PRIVATE_KEY" | ssh-add -
                                      -----^
查看更多
登录 后发表回答