I use the following line in a gitlab pipeline :
scp -i "$SSH_PRIVATE_KEY" -r dist user@1.1.1.1:/home/user/preprod
However when this line is executed the private key is prompted in the pipeline console, which is obviously a security issue.
The server is ubuntu 18.04
$SSH_PRIVATE_KEY
? Is it a filename as it is supposed to be? – PerlDuck Sep 14 '18 at 14:08scp -i
expects the name of the file that contains the private key, e.g./home/username/.ssh/id_rsa
and I was asking whether your$SSH_PRIVATE_KEY
contains something similar. – PerlDuck Sep 14 '18 at 14:16-----BEGIN RSA PRIVATE KEY----- MIIEsexz4...
). That's wrong. It should contain the name of the file that contains the key, not the key itself. – PerlDuck Sep 14 '18 at 14:33echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
before thescp -i
line allow me to usescp
without the-i
option – L. Faros Sep 14 '18 at 14:43