Note that there are some explanatory texts on larger screens.

plurals
  1. POSFTP and Camel. Cannot change directory to. Invalid privateKey
    text
    copied!<p>I need to connect to ftp server via sftp. I successfully connectewd via ftp and ftps with camel.</p> <pre><code>public static RouteBuilder getRouteBuilderSFTPS() { return new RouteBuilder() { public void configure() { from("sftp://666.66.666.66:22/POLP-FROAKS?fileName=testMsg.txt&amp;username=POLP-FROAKS&amp;password=pass&amp;strictHostKeyChecking=no&amp;ciphers=blowfish-cbc,aes128-ctr,aes128-cbc,3des-ctr,3des-cbc,aes192-cbc,aes256-cbc"). to("file://target/test-reports667"); } }; } </code></pre> <p>I get respone org.apache.camel.component.file.GenericFileOperationFailedException: Cannot change directory to: POLP-FROAKS</p> <p>Full log:</p> <pre><code>16:25:32,758 INFO (main) [DefaultCamelContext] Apache Camel 2.9.2 (CamelContext: camel-1) started in 0.472 seconds Apache Camel 2.9.2 (CamelContext: camel-1) started in 0.472 seconds 16:25:33,749 DEBUG (Camel (camel-1) thread #1 - sftp://216.66.216.10:22/POLP-FROAKS) [SftpConsumer] Not connected/logged in, connecting to: sftp://POLP-FROAKS@216.66.216.10:22 Not connected/logged in, connecting to: sftp://POLP-FROAKS@216.66.216.10:22 16:25:33,753 DEBUG (Camel (camel-1) thread #1 - sftp://216.66.216.10:22/POLP-FROAKS) [SftpOperations] Using ciphers: blowfish-cbc,aes128-ctr,aes128-cbc,3des-ctr,3des-cbc,aes192-cbc,aes256-cbc Using ciphers: blowfish-cbc,aes128-ctr,aes128-cbc,3des-ctr,3des-cbc,aes192-cbc,aes256-cbc 16:25:33,764 DEBUG (Camel (camel-1) thread #1 - sftp://216.66.216.10:22/POLP-FROAKS) [SftpOperations] Using StrickHostKeyChecking: no Using StrickHostKeyChecking: no 16:25:33,769 INFO (Camel (camel-1) thread #1 - sftp://216.66.216.10:22/POLP-FROAKS) [SftpOperations] JSCH -&gt; Connecting to 216.66.216.10 port 22 JSCH -&gt; Connecting to 216.66.216.10 port 22 16:25:34,099 INFO (Camel (camel-1) thread #1 - sftp://216.66.216.10:22/POLP-FROAKS) [SftpOperations] JSCH -&gt; Connection established JSCH -&gt; Connection established 16:25:34,476 INFO (Camel (camel-1) thread #1 - sftp://216.66.216.10:22/POLP-FROAKS) [SftpOperations] JSCH -&gt; Remote version string: SSH-2.0-OpenSSH_4.3 JSCH -&gt; Remote version string: SSH-2.0-OpenSSH_4.3 16:25:34,476 INFO (Camel (camel-1) thread #1 - sftp://216.66.216.10:22/POLP-FROAKS) [SftpOperations] JSCH -&gt; Local version string: SSH-2.0-JSCH-0.1.48 JSCH -&gt; Local version string: SSH-2.0-JSCH-0.1.48 16:25:34,476 INFO (Camel (camel-1) thread #1 - sftp://216.66.216.10:22/POLP-FROAKS) [SftpOperations] JSCH -&gt; CheckCiphers: aes256-ctr,aes192-ctr,aes128-ctr,aes256-cbc,aes192-cbc,aes128-cbc,3des-ctr,arcfour,arcfour128,arcfour256 JSCH -&gt; CheckCiphers: aes256-ctr,aes192-ctr,aes128-ctr,aes256-cbc,aes192-cbc,aes128-cbc,3des-ctr,arcfour,arcfour128,arcfour256 16:25:34,760 INFO (Camel (camel-1) thread #1 - sftp://216.66.216.10:22/POLP-FROAKS) [SftpOperations] JSCH -&gt; aes256-ctr is not available. JSCH -&gt; aes256-ctr is not available. 16:25:34,760 INFO (Camel (camel-1) thread #1 - sftp://216.66.216.10:22/POLP-FROAKS) [SftpOperations] JSCH -&gt; aes192-ctr is not available. JSCH -&gt; aes192-ctr is not available. 16:25:34,760 INFO (Camel (camel-1) thread #1 - sftp://216.66.216.10:22/POLP-FROAKS) [SftpOperations] JSCH -&gt; aes256-cbc is not available. JSCH -&gt; aes256-cbc is not available. 16:25:34,760 INFO (Camel (camel-1) thread #1 - sftp://216.66.216.10:22/POLP-FROAKS) [SftpOperations] JSCH -&gt; aes192-cbc is not available. JSCH -&gt; aes192-cbc is not available. 16:25:34,760 INFO (Camel (camel-1) thread #1 - sftp://216.66.216.10:22/POLP-FROAKS) [SftpOperations] JSCH -&gt; arcfour256 is not available. JSCH -&gt; arcfour256 is not available. 16:25:34,761 INFO (Camel (camel-1) thread #1 - sftp://216.66.216.10:22/POLP-FROAKS) [SftpOperations] JSCH -&gt; CheckKexes: diffie-hellman-group14-sha1 JSCH -&gt; CheckKexes: diffie-hellman-group14-sha1 16:25:34,768 INFO (Camel (camel-1) thread #1 - sftp://216.66.216.10:22/POLP-FROAKS) [SftpOperations] JSCH -&gt; diffie-hellman-group14-sha1 is not available. JSCH -&gt; diffie-hellman-group14-sha1 is not available. 16:25:34,804 INFO (Camel (camel-1) thread #1 - sftp://216.66.216.10:22/POLP-FROAKS) [SftpOperations] JSCH -&gt; SSH_MSG_KEXINIT sent JSCH -&gt; SSH_MSG_KEXINIT sent 16:25:34,988 INFO (Camel (camel-1) thread #1 - sftp://216.66.216.10:22/POLP-FROAKS) [SftpOperations] JSCH -&gt; SSH_MSG_KEXINIT received JSCH -&gt; SSH_MSG_KEXINIT received 16:25:34,988 INFO (Camel (camel-1) thread #1 - sftp://216.66.216.10:22/POLP-FROAKS) [SftpOperations] JSCH -&gt; kex: server: diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1 JSCH -&gt; kex: server: diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1 16:25:34,988 INFO (Camel (camel-1) thread #1 - sftp://216.66.216.10:22/POLP-FROAKS) [SftpOperations] JSCH -&gt; kex: server: ssh-rsa,ssh-dss,ssh-dss,ssh-rsa JSCH -&gt; kex: server: ssh-rsa,ssh-dss,ssh-dss,ssh-rsa 16:25:34,988 INFO (Camel (camel-1) thread #1 - sftp://216.66.216.10:22/POLP-FROAKS) [SftpOperations] JSCH -&gt; kex: server: aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour128,arcfour256,arcfour,aes192-cbc,aes256-cbc,aes128-ctr,aes192-ctr,aes256-ctr JSCH -&gt; kex: server: aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour128,arcfour256,arcfour,aes192-cbc,aes256-cbc,aes128-ctr,aes192-ctr,aes256-ctr 16:25:34,988 INFO (Camel (camel-1) thread #1 - sftp://216.66.216.10:22/POLP-FROAKS) [SftpOperations] JSCH -&gt; kex: server: aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour128,arcfour256,arcfour,aes192-cbc,aes256-cbc,aes128-ctr,aes192-ctr,aes256-ctr JSCH -&gt; kex: server: aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour128,arcfour256,arcfour,aes192-cbc,aes256-cbc,aes128-ctr,aes192-ctr,aes256-ctr 16:25:34,988 INFO (Camel (camel-1) thread #1 - sftp://216.66.216.10:22/POLP-FROAKS) [SftpOperations] JSCH -&gt; kex: server: hmac-md5,hmac-sha1,hmac-ripemd160,hmac-sha1-96,hmac-md5-96 JSCH -&gt; kex: server: hmac-md5,hmac-sha1,hmac-ripemd160,hmac-sha1-96,hmac-md5-96 16:25:34,988 INFO (Camel (camel-1) thread #1 - sftp://216.66.216.10:22/POLP-FROAKS) [SftpOperations] JSCH -&gt; kex: server: hmac-md5,hmac-sha1,hmac-ripemd160,hmac-sha1-96,hmac-md5-96 JSCH -&gt; kex: server: hmac-md5,hmac-sha1,hmac-ripemd160,hmac-sha1-96,hmac-md5-96 16:25:34,988 INFO (Camel (camel-1) thread #1 - sftp://216.66.216.10:22/POLP-FROAKS) [SftpOperations] JSCH -&gt; kex: server: none,zlib@openssh.com JSCH -&gt; kex: server: none,zlib@openssh.com 16:25:34,988 INFO (Camel (camel-1) thread #1 - sftp://216.66.216.10:22/POLP-FROAKS) [SftpOperations] JSCH -&gt; kex: server: none,zlib@openssh.com JSCH -&gt; kex: server: none,zlib@openssh.com 16:25:34,988 INFO (Camel (camel-1) thread #1 - sftp://216.66.216.10:22/POLP-FROAKS) [SftpOperations] JSCH -&gt; kex: server: JSCH -&gt; kex: server: 16:25:34,988 INFO (Camel (camel-1) thread #1 - sftp://216.66.216.10:22/POLP-FROAKS) [SftpOperations] JSCH -&gt; kex: server: JSCH -&gt; kex: server: 16:25:34,988 INFO (Camel (camel-1) thread #1 - sftp://216.66.216.10:22/POLP-FROAKS) [SftpOperations] JSCH -&gt; kex: client: diffie-hellman-group1-sha1,diffie-hellman-group-exchange-sha1 JSCH -&gt; kex: client: diffie-hellman-group1-sha1,diffie-hellman-group-exchange-sha1 16:25:34,988 INFO (Camel (camel-1) thread #1 - sftp://216.66.216.10:22/POLP-FROAKS) [SftpOperations] JSCH -&gt; kex: client: ssh-rsa,ssh-dss JSCH -&gt; kex: client: ssh-rsa,ssh-dss 16:25:34,989 INFO (Camel (camel-1) thread #1 - sftp://216.66.216.10:22/POLP-FROAKS) [SftpOperations] JSCH -&gt; kex: client: blowfish-cbc,aes128-ctr,aes128-cbc,3des-ctr,3des-cbc JSCH -&gt; kex: client: blowfish-cbc,aes128-ctr,aes128-cbc,3des-ctr,3des-cbc 16:25:34,989 INFO (Camel (camel-1) thread #1 - sftp://216.66.216.10:22/POLP-FROAKS) [SftpOperations] JSCH -&gt; kex: client: blowfish-cbc,aes128-ctr,aes128-cbc,3des-ctr,3des-cbc JSCH -&gt; kex: client: blowfish-cbc,aes128-ctr,aes128-cbc,3des-ctr,3des-cbc 16:25:34,989 INFO (Camel (camel-1) thread #1 - sftp://216.66.216.10:22/POLP-FROAKS) [SftpOperations] JSCH -&gt; kex: client: hmac-md5,hmac-sha1,hmac-sha1-96,hmac-md5-96 JSCH -&gt; kex: client: hmac-md5,hmac-sha1,hmac-sha1-96,hmac-md5-96 16:25:34,989 INFO (Camel (camel-1) thread #1 - sftp://216.66.216.10:22/POLP-FROAKS) [SftpOperations] JSCH -&gt; kex: client: hmac-md5,hmac-sha1,hmac-sha1-96,hmac-md5-96 JSCH -&gt; kex: client: hmac-md5,hmac-sha1,hmac-sha1-96,hmac-md5-96 16:25:34,989 INFO (Camel (camel-1) thread #1 - sftp://216.66.216.10:22/POLP-FROAKS) [SftpOperations] JSCH -&gt; kex: client: none JSCH -&gt; kex: client: none 16:25:34,989 INFO (Camel (camel-1) thread #1 - sftp://216.66.216.10:22/POLP-FROAKS) [SftpOperations] JSCH -&gt; kex: client: none JSCH -&gt; kex: client: none 16:25:34,989 INFO (Camel (camel-1) thread #1 - sftp://216.66.216.10:22/POLP-FROAKS) [SftpOperations] JSCH -&gt; kex: client: JSCH -&gt; kex: client: 16:25:34,989 INFO (Camel (camel-1) thread #1 - sftp://216.66.216.10:22/POLP-FROAKS) [SftpOperations] JSCH -&gt; kex: client: JSCH -&gt; kex: client: 16:25:34,989 INFO (Camel (camel-1) thread #1 - sftp://216.66.216.10:22/POLP-FROAKS) [SftpOperations] JSCH -&gt; kex: server-&gt;client blowfish-cbc hmac-md5 none JSCH -&gt; kex: server-&gt;client blowfish-cbc hmac-md5 none 16:25:34,989 INFO (Camel (camel-1) thread #1 - sftp://216.66.216.10:22/POLP-FROAKS) [SftpOperations] JSCH -&gt; kex: client-&gt;server blowfish-cbc hmac-md5 none JSCH -&gt; kex: client-&gt;server blowfish-cbc hmac-md5 none 16:25:35,015 INFO (Camel (camel-1) thread #1 - sftp://216.66.216.10:22/POLP-FROAKS) [SftpOperations] JSCH -&gt; SSH_MSG_KEXDH_INIT sent JSCH -&gt; SSH_MSG_KEXDH_INIT sent 16:25:35,015 INFO (Camel (camel-1) thread #1 - sftp://216.66.216.10:22/POLP-FROAKS) [SftpOperations] JSCH -&gt; expecting SSH_MSG_KEXDH_REPLY JSCH -&gt; expecting SSH_MSG_KEXDH_REPLY 16:25:35,451 INFO (Camel (camel-1) thread #1 - sftp://216.66.216.10:22/POLP-FROAKS) [SftpOperations] JSCH -&gt; ssh_rsa_verify: signature true JSCH -&gt; ssh_rsa_verify: signature true 16:25:35,455 WARN (Camel (camel-1) thread #1 - sftp://216.66.216.10:22/POLP-FROAKS) [SftpOperations] JSCH -&gt; Permanently added '216.66.216.10' (RSA) to the list of known hosts. JSCH -&gt; Permanently added '216.66.216.10' (RSA) to the list of known hosts. 16:25:35,455 INFO (Camel (camel-1) thread #1 - sftp://216.66.216.10:22/POLP-FROAKS) [SftpOperations] JSCH -&gt; SSH_MSG_NEWKEYS sent JSCH -&gt; SSH_MSG_NEWKEYS sent 16:25:35,455 INFO (Camel (camel-1) thread #1 - sftp://216.66.216.10:22/POLP-FROAKS) [SftpOperations] JSCH -&gt; SSH_MSG_NEWKEYS received JSCH -&gt; SSH_MSG_NEWKEYS received 16:25:35,466 INFO (Camel (camel-1) thread #1 - sftp://216.66.216.10:22/POLP-FROAKS) [SftpOperations] JSCH -&gt; SSH_MSG_SERVICE_REQUEST sent JSCH -&gt; SSH_MSG_SERVICE_REQUEST sent 16:25:35,779 INFO (Camel (camel-1) thread #1 - sftp://216.66.216.10:22/POLP-FROAKS) [SftpOperations] JSCH -&gt; SSH_MSG_SERVICE_ACCEPT received JSCH -&gt; SSH_MSG_SERVICE_ACCEPT received 16:25:36,093 INFO (Camel (camel-1) thread #1 - sftp://216.66.216.10:22/POLP-FROAKS) [SftpOperations] JSCH -&gt; Authentications that can continue: publickey,keyboard-interactive,password JSCH -&gt; Authentications that can continue: publickey,keyboard-interactive,password 16:25:36,094 INFO (Camel (camel-1) thread #1 - sftp://216.66.216.10:22/POLP-FROAKS) [SftpOperations] JSCH -&gt; Next authentication method: publickey JSCH -&gt; Next authentication method: publickey 16:25:36,095 INFO (Camel (camel-1) thread #1 - sftp://216.66.216.10:22/POLP-FROAKS) [SftpOperations] JSCH -&gt; Authentications that can continue: password JSCH -&gt; Authentications that can continue: password 16:25:36,095 INFO (Camel (camel-1) thread #1 - sftp://216.66.216.10:22/POLP-FROAKS) [SftpOperations] JSCH -&gt; Next authentication method: password JSCH -&gt; Next authentication method: password 16:25:36,835 INFO (Camel (camel-1) thread #1 - sftp://216.66.216.10:22/POLP-FROAKS) [SftpOperations] JSCH -&gt; Authentication succeeded (password). JSCH -&gt; Authentication succeeded (password). 16:25:37,932 INFO (Camel (camel-1) thread #1 - sftp://216.66.216.10:22/POLP-FROAKS) [SftpOperations] Connected to sftp://POLP-FROAKS@216.66.216.10:22 Connected to sftp://POLP-FROAKS@216.66.216.10:22 16:25:37,932 INFO (Camel (camel-1) thread #1 - sftp://216.66.216.10:22/POLP-FROAKS) [SftpConsumer] Connected and logged in to: sftp://POLP-FROAKS@216.66.216.10:22 Connected and logged in to: sftp://POLP-FROAKS@216.66.216.10:22 16:25:38,966 WARN (Camel (camel-1) thread #1 - sftp://216.66.216.10:22/POLP-FROAKS) [RemoteFilePollingConsumerPollStrategy] Trying to recover by disconnecting from remote server forcing a re-connect at next poll: sftp://POLP-FROAKS@216.66.216.10:22 Trying to recover by disconnecting from remote server forcing a re-connect at next poll: sftp://POLP-FROAKS@216.66.216.10:22 16:25:38,966 DEBUG (Camel (camel-1) thread #1 - sftp://216.66.216.10:22/POLP-FROAKS) [SftpConsumer] Disconnecting from: sftp://POLP-FROAKS@216.66.216.10:22 Disconnecting from: sftp://POLP-FROAKS@216.66.216.10:22 16:25:38,966 INFO (Camel (camel-1) thread #1 - sftp://216.66.216.10:22/POLP-FROAKS) [SftpOperations] JSCH -&gt; Disconnecting from 216.66.216.10 port 22 JSCH -&gt; Disconnecting from 216.66.216.10 port 22 16:25:38,971 INFO (Connect thread 216.66.216.10 session) [SftpOperations] JSCH -&gt; Caught an exception, leaving main loop due to socket closed JSCH -&gt; Caught an exception, leaving main loop due to socket closed 16:25:38,977 WARN (Camel (camel-1) thread #1 - sftp://216.66.216.10:22/POLP-FROAKS) [RemoteFilePollingConsumerPollStrategy] Consumer Consumer[sftp://216.66.216.10:22/POLP-FROAKS?ciphers=blowfish-cbc,aes128-ctr,aes128-cbc,3des-ctr,3des-cbc,aes192-cbc,aes256-cbc&amp;fileName=testMsg.txt&amp;password=******&amp;strictHostKeyChecking=no&amp;username=POLP-FROAKS] could not poll endpoint: Endpoint[sftp://216.66.216.10:22/POLP-FROAKS?ciphers=blowfish-cbc,aes128-ctr,aes128-cbc,3des-ctr,3des-cbc,aes192-cbc,aes256-cbc&amp;fileName=testMsg.txt&amp;password=******&amp;strictHostKeyChecking=no&amp;username=POLP-FROAKS] caused by: Cannot change directory to: POLP-FROAKS org.apache.camel.component.file.GenericFileOperationFailedException: Cannot change directory to: POLP-FROAKS at org.apache.camel.component.file.remote.SftpOperations.doChangeDirectory(SftpOperations.java:423) at org.apache.camel.component.file.remote.SftpOperations.changeCurrentDirectory(SftpOperations.java:410) at org.apache.camel.component.file.remote.SftpConsumer.doPollDirectory(SftpConsumer.java:78) at org.apache.camel.component.file.remote.SftpConsumer.pollDirectory(SftpConsumer.java:50) at org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:100) at org.apache.camel.impl.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:138) at org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:90) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441) at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:317) at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:98) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.java:180) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:204) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:662) Caused by: 2: No such file at com.jcraft.jsch.ChannelSftp.throwStatusError(ChannelSftp.java:2569) at com.jcraft.jsch.ChannelSftp._stat(ChannelSftp.java:2018) at com.jcraft.jsch.ChannelSftp.cd(ChannelSftp.java:316) at org.apache.camel.component.file.remote.SftpOperations.doChangeDirectory(SftpOperations.java:421) ... 15 more </code></pre> <p>I have same code but without camel and it works. What is wrong with camel version? Also I'm little confused why server doesn't ask me about private key?</p> <p>UPDATE:</p> <p>I'm trying to add private key:</p> <pre><code>JSch.setLogger(new MyJschLogger()); JSch ssh = new JSch(); final byte[] privateKey = getPrivateKeyAsByteStream(privateKeyPath); final byte[] passPrivateKey = "".getBytes(); //TODO DB: invalid private key. If not use private key than we can download file ssh.addIdentity(username, privateKey, null, passPrivateKey); session = ssh.getSession(username, server, port); session.setPassword(password); session.setConfig("StrictHostKeyChecking", "no"); session.connect(); channel = session.openChannel("sftp"); channel.connect(); ChannelSftp sftp = (ChannelSftp) channel; final Vector files = sftp.ls("."); Iterator itFiles = files.iterator(); while (itFiles.hasNext()) { System.out.println("Index: " + itFiles.next()); } sftp.get(remoteFile, localFile); sftp.exit(); </code></pre> <p>Key was readed but I got the error:</p> <pre><code>com.jcraft.jsch.JSchException: invalid privatekey: POLP-FROAKS at com.jcraft.jsch.IdentityFile.&lt;init&gt;(IdentityFile.java:302) at com.jcraft.jsch.IdentityFile.newInstance(IdentityFile.java:135) at com.jcraft.jsch.JSch.addIdentity(JSch.java:390) at com.nxsystems.camel.Main.retrieveFileViaSFTP(Main.java:204) at com.nxsystems.camel.Main.main(Main.java:29) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120) </code></pre> <p>Key was generated with PuTTY. FilleZilla accepted key normally. Why????</p> <p>UPDATE: noup. Problem is not in keys. I converted key in putty format to openssh format with puttyge.exe->conversion and JSCH accepted it successfuly. But old error "Cannot change directory to..." is back...</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload