Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

linux

bash

sh

ssh

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
like image 950
Dimitri Kopriwa Avatar asked May 26 '17 23:05

Dimitri Kopriwa


People also ask

Does Alpine have ssh?

Installing OpenSSH server on Alpine Linux Edit the /etc/ssh/sshd_config for customization purpose. By default, sshd on Alpine Linux will use TCP port 22.

What is the shell for Alpine?

– The default shell in Alpine is the busybox provided ash.

Does Alpine Linux have bash?

There is no Bash installed by default; Alpine uses BusyBox Bash as the default shell.


Video Answer


2 Answers

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 -
                                      -----^
like image 83
that other guy Avatar answered Oct 13 '22 22:10

that other guy


You should use this command:

echo "$SSH_PRIVATE_KEY" | ssh-add -
like image 38
Haniyeh Asemi Avatar answered Oct 13 '22 21:10

Haniyeh Asemi