bash 有没有`ssh-add` Linux alpine one liner
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/44211396/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Is there a `ssh-add` Linux alpine one liner
提问by Dimitri Kopriwa
I need during a Gitlab-CI build to authenticate with ssh-agent from an alpine image.
我需要在 Gitlab-CI 构建期间使用 ssh-agent 从高山图像进行身份验证。
I am looking for a shone liner equivalent of this bashcommand (picked from the gitlab documentation):
我正在寻找一个shone liner 相当于这个bash命令(从 gitlab 文档中挑选):
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
回答by that other guy
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 -
-----^