I just tried the same thing on a linux machine (redhat), and got exactly the 
same error. But then, when I tried privateKeyFile (not documented on the 
scp/Jsch camel page) instead of username/password, to make it use private key 
verification, then it just worked on the first attempt (private key 
verification was already setup between these servers). A bit strange that 
something as simple as username and password verification doesn't work, but 
something more complicated works right away.

Anyway, since private key verification was my final goal, I think I will settle 
with this and not really investigate further. :)

/Jimi


-----Original Message-----
From: jimi.hulleg...@svensktnaringsliv.se 
[mailto:jimi.hulleg...@svensktnaringsliv.se] 
Sent: Monday, June 20, 2016 12:34 PM
To: users@camel.apache.org
Subject: Can't get scp to work

Hi,

I'm trying to setup a simple (in my eyes) file transfer between servers, and 
when configuring this I am trying to transfer files from my windows machine to 
a remote server. But I simply can't get it to work.

The route looks like this:

<route>
                         <from 
uri="file:{{inputDirectory}}?include=(?i).*\.*&amp;delete=true&amp;delay=5000&amp;filter=#fileFilter"
 />
                         <to 
uri="scp://our-server/tmp/?username=user&amp;password=password&amp;strictHostKeyChecking=no"
 /> </route>

First, it complained about the missing file C:\Users\username\.ssh\known_hosts. 
When I created that file and tried again, it complains about "Auth cancel".

Here is the stacktrace:

2016-06-20 10:05:50,926 [Camel (camel-1) thread #0] WARN  
org.apache.camel.component.scp.ScpOperations - Could not create ssh session for 
scp://user@our-server:22 com.jcraft.jsch.JSchException: Auth cancel
                         at com.jcraft.jsch.Session.connect(Session.java:511)
                         at 
org.apache.camel.component.scp.ScpOperations.createSession(ScpOperations.java:253)
                         at 
org.apache.camel.component.scp.ScpOperations.connect(ScpOperations.java:179)
                         at 
org.apache.camel.component.file.remote.RemoteFileProducer.connectIfNecessary(RemoteFileProducer.java:209)
                         at 
org.apache.camel.component.file.remote.RemoteFileProducer.recoverableConnectIfNecessary(RemoteFileProducer.java:179)
                         at 
org.apache.camel.component.file.remote.RemoteFileProducer.preWriteCheck(RemoteFileProducer.java:133)
                         at 
org.apache.camel.component.file.GenericFileProducer.processExchange(GenericFileProducer.java:113)
                         at 
org.apache.camel.component.file.remote.RemoteFileProducer.process(RemoteFileProducer.java:58)
                         ...

In the code for com.jcraft.jsch.Session I see that the original 
JSchAuthCancelException is caught and swallowed (except setting 
auth_cancel=true) on line 471. But when debugging this in Eclipse I get some 
more information about the error. For example I can see that the message/method 
is "keyboard-interactive", the kex is of the type com.jcraft.jsch.DHG14 and 
it's key_alg_name is "ssh-rsa". Maybe this says something important to someone. 
But the thing that sticks out for me is that the javadoc for DHG14 
(http://epaul.github.io/jsch-documentation/javadoc/com/jcraft/jsch/DHG14.html) 
specifically says "Usually not to be used by applications", which could be an 
indication that the wrong KeyExchange type is used, right? The javadoc also 
says that it "Implements the key exchange method diffie-hellman-group1-sha1, 
using the Oakley Group 14".

Is it possible to make Camel use a different KeyExchange type? I can't find any 
documentation about this. In fact, the scp support in Camel is not really 
documented much at all, if you ask me.

If it is not possible to change the KeyExchange type, what other options to I 
have to make scp work?

I use Camel 2.17.0, and sftp with the same server, username and password works 
just fine.

Regards
/Jimi

Reply via email to