I am using latest Linux Alpine (3.6) as OS in a docker container (also tested on Ubuntu 16.10 outside of Docker with same result).

I have installed openssh (apk add openssh).

Here is my command :

scp -i $KEY_PATH -P $PORT -o StrictHostKeyChecking=no $USER@$HOST:$FILENAME .

When scp successfully copies a file, it exists with 0 (expected).

When the file is not found, scp says : No such file or directory but does not exits. What can I do to get a proper exit with a non 0 code ? Could it be a problem on the server or network ?

  • As an aside, double-quote your variables, such as "$KEYPATH". Try to avoid using $USER - you're either overriding a standard variable or it's an unnecessary part of the command (and just use "$HOST:$FILENAME") – roaima Jul 7 '17 at 16:02
  • Where would $USER be defined elsewhere ? inside the key ? – Tristan Jul 8 '17 at 6:25
  • It's defined by login and inherited from the shell (bash or whatever). For your own variables it's general better to use lower case names. – roaima Jul 8 '17 at 7:55
  • Ok, thanks. If you have some friends who have some intels about the question itself, I'd be rly grateful. – Tristan Jul 9 '17 at 8:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.