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

杀马特。学长 韩版系。学妹 提交于 2019-12-05 20:07:03

问题


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

回答1:


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 -
                                      -----^


来源:https://stackoverflow.com/questions/44211396/is-there-a-ssh-add-linux-alpine-one-liner

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!