With the ec2-plugin I just got the stacktrace below from a customer.
Oct 13, 2017 3:51:57 PM null
INFO: Copying slave.jar
ERROR: Error during SCP transfer.
java.io.IOException: Error during SCP transfer.
at com.trilead.ssh2.SCPClient.put(SCPClient.java:523)
at com.trilead.ssh2.SCPClient.put(SCPClient.java:476)
at hudson.plugins.ec2.ssh.EC2UnixLauncher.launch(EC2UnixLauncher.java:214)
at hudson.plugins.ec2.EC2ComputerLauncher.launch(EC2ComputerLauncher.java:122)
at hudson.slaves.SlaveComputer$1.call(SlaveComputer.java:262)
at jenkins.util.ContextResettingExecutorService$2.call(ContextResettingExecutorService.java:46)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.io.IOException: Remote scp sent illegal error code.
at com.trilead.ssh2.SCPClient.readResponse(SCPClient.java:53)
at com.trilead.ssh2.SCPClient.sendBytes(SCPClient.java:140)
at com.trilead.ssh2.SCPClient.put(SCPClient.java:519)
... 9 more
The problem I see with readResponse is that it does NOT tells what is the SCP error code received, so it is difficult to understand the reason why the operation failed.