How to pass in the password in scp using Java ssh JSch and jcabi-ssh
<p>I need to execute following command:</p>

<pre><code>scp -r ~/dataIn yatsuk@192.168.1.1:~/dataOut
</code></pre>

<p>In ubuntu (16.04) terminal this command work correctly. 
yatsuk@192.168.1.1 is localhost.</p>

<p>So I try this code using jcabi:</p>

<pre><code>Shell shell = new SSHByPassword("192.168.1.1", 22, "yatsuk", "passw");
String stdout = new Shell.Plain(shell).exec("scp -r ~/dataIn yatsuk@192.168.1.1:~/dataOut");
System.out.println(stdout);
</code></pre>

<p>And this code by JSch:</p>

<pre><code>JSch jsch = new JSch();
JSch.setConfig("StrictHostKeyChecking", "no");
Session session = jsch.getSession("yatsuk", 192.168.1.1, 22);
session.setPassword("passw");
session.connect();

Channel channel = session.openChannel("exec");
((ChannelExec) channel).setCommand("scp -r ~/dataIn yatsuk@192.168.1.1:~/dataOut");
((ChannelExec) channel).setErrStream(System.err);
channel.setOutputStream(System.out);
channel.setInputStream(System.in);
channel.connect();

while (!channel.isClosed()) {
    Thread.sleep(1000);
}
channel.disconnect();
session.disconnect();
</code></pre>

<p>Both return me:</p>

<pre><code>Permission denied, please try again.
Permission denied, please try again.
Permission denied (publickey,password).
lost connection
</code></pre>

<p>Simple commands like "echo 1 > 1.txt" works perfectly.
Maybe something I do not understand?</p>