sftp経由でftpサーバーに接続する必要があります。ftp と ftps を介してラクダと正常に接続できました。
public static RouteBuilder getRouteBuilderSFTPS() {
return new RouteBuilder() {
public void configure() {
from("sftp://666.66.666.66:22/POLP-FROAKS?fileName=testMsg.txt&username=POLP-FROAKS&password=pass&strictHostKeyChecking=no&ciphers=blowfish-cbc,aes128-ctr,aes128-cbc,3des-ctr,3des-cbc,aes192-cbc,aes256-cbc").
to("file://target/test-reports667");
}
};
}
respone org.apache.camel.component.file.GenericFileOperationFailedException: Cannot change directory to: POLP-FROAKS を取得します
完全なログ:
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 -> Connecting to 216.66.216.10 port 22
JSCH -> 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 -> Connection established
JSCH -> Connection established
16:25:34,476 INFO (Camel (camel-1) thread #1 - sftp://216.66.216.10:22/POLP-FROAKS) [SftpOperations] JSCH -> Remote version string: SSH-2.0-OpenSSH_4.3
JSCH -> 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 -> Local version string: SSH-2.0-JSCH-0.1.48
JSCH -> 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 -> CheckCiphers: aes256-ctr,aes192-ctr,aes128-ctr,aes256-cbc,aes192-cbc,aes128-cbc,3des-ctr,arcfour,arcfour128,arcfour256
JSCH -> 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 -> aes256-ctr is not available.
JSCH -> 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 -> aes192-ctr is not available.
JSCH -> 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 -> aes256-cbc is not available.
JSCH -> 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 -> aes192-cbc is not available.
JSCH -> 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 -> arcfour256 is not available.
JSCH -> arcfour256 is not available.
16:25:34,761 INFO (Camel (camel-1) thread #1 - sftp://216.66.216.10:22/POLP-FROAKS) [SftpOperations] JSCH -> CheckKexes: diffie-hellman-group14-sha1
JSCH -> 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 -> diffie-hellman-group14-sha1 is not available.
JSCH -> 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 -> SSH_MSG_KEXINIT sent
JSCH -> SSH_MSG_KEXINIT sent
16:25:34,988 INFO (Camel (camel-1) thread #1 - sftp://216.66.216.10:22/POLP-FROAKS) [SftpOperations] JSCH -> SSH_MSG_KEXINIT received
JSCH -> SSH_MSG_KEXINIT received
16:25:34,988 INFO (Camel (camel-1) thread #1 - sftp://216.66.216.10:22/POLP-FROAKS) [SftpOperations] JSCH -> kex: server: diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
JSCH -> 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 -> kex: server: ssh-rsa,ssh-dss,ssh-dss,ssh-rsa
JSCH -> 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 -> kex: server: aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour128,arcfour256,arcfour,aes192-cbc,aes256-cbc,aes128-ctr,aes192-ctr,aes256-ctr
JSCH -> 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 -> kex: server: aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour128,arcfour256,arcfour,aes192-cbc,aes256-cbc,aes128-ctr,aes192-ctr,aes256-ctr
JSCH -> 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 -> kex: server: hmac-md5,hmac-sha1,hmac-ripemd160,hmac-sha1-96,hmac-md5-96
JSCH -> 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 -> kex: server: hmac-md5,hmac-sha1,hmac-ripemd160,hmac-sha1-96,hmac-md5-96
JSCH -> 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 -> kex: server: none,zlib@openssh.com
JSCH -> 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 -> kex: server: none,zlib@openssh.com
JSCH -> 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 -> kex: server:
JSCH -> kex: server:
16:25:34,988 INFO (Camel (camel-1) thread #1 - sftp://216.66.216.10:22/POLP-FROAKS) [SftpOperations] JSCH -> kex: server:
JSCH -> kex: server:
16:25:34,988 INFO (Camel (camel-1) thread #1 - sftp://216.66.216.10:22/POLP-FROAKS) [SftpOperations] JSCH -> kex: client: diffie-hellman-group1-sha1,diffie-hellman-group-exchange-sha1
JSCH -> 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 -> kex: client: ssh-rsa,ssh-dss
JSCH -> 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 -> kex: client: blowfish-cbc,aes128-ctr,aes128-cbc,3des-ctr,3des-cbc
JSCH -> 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 -> kex: client: blowfish-cbc,aes128-ctr,aes128-cbc,3des-ctr,3des-cbc
JSCH -> 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 -> kex: client: hmac-md5,hmac-sha1,hmac-sha1-96,hmac-md5-96
JSCH -> 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 -> kex: client: hmac-md5,hmac-sha1,hmac-sha1-96,hmac-md5-96
JSCH -> 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 -> kex: client: none
JSCH -> kex: client: none
16:25:34,989 INFO (Camel (camel-1) thread #1 - sftp://216.66.216.10:22/POLP-FROAKS) [SftpOperations] JSCH -> kex: client: none
JSCH -> kex: client: none
16:25:34,989 INFO (Camel (camel-1) thread #1 - sftp://216.66.216.10:22/POLP-FROAKS) [SftpOperations] JSCH -> kex: client:
JSCH -> kex: client:
16:25:34,989 INFO (Camel (camel-1) thread #1 - sftp://216.66.216.10:22/POLP-FROAKS) [SftpOperations] JSCH -> kex: client:
JSCH -> kex: client:
16:25:34,989 INFO (Camel (camel-1) thread #1 - sftp://216.66.216.10:22/POLP-FROAKS) [SftpOperations] JSCH -> kex: server->client blowfish-cbc hmac-md5 none
JSCH -> kex: server->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 -> kex: client->server blowfish-cbc hmac-md5 none
JSCH -> kex: client->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 -> SSH_MSG_KEXDH_INIT sent
JSCH -> 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 -> expecting SSH_MSG_KEXDH_REPLY
JSCH -> 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 -> ssh_rsa_verify: signature true
JSCH -> 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 -> Permanently added '216.66.216.10' (RSA) to the list of known hosts.
JSCH -> 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 -> SSH_MSG_NEWKEYS sent
JSCH -> SSH_MSG_NEWKEYS sent
16:25:35,455 INFO (Camel (camel-1) thread #1 - sftp://216.66.216.10:22/POLP-FROAKS) [SftpOperations] JSCH -> SSH_MSG_NEWKEYS received
JSCH -> SSH_MSG_NEWKEYS received
16:25:35,466 INFO (Camel (camel-1) thread #1 - sftp://216.66.216.10:22/POLP-FROAKS) [SftpOperations] JSCH -> SSH_MSG_SERVICE_REQUEST sent
JSCH -> 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 -> SSH_MSG_SERVICE_ACCEPT received
JSCH -> 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 -> Authentications that can continue: publickey,keyboard-interactive,password
JSCH -> 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 -> Next authentication method: publickey
JSCH -> Next authentication method: publickey
16:25:36,095 INFO (Camel (camel-1) thread #1 - sftp://216.66.216.10:22/POLP-FROAKS) [SftpOperations] JSCH -> Authentications that can continue: password
JSCH -> 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 -> Next authentication method: password
JSCH -> Next authentication method: password
16:25:36,835 INFO (Camel (camel-1) thread #1 - sftp://216.66.216.10:22/POLP-FROAKS) [SftpOperations] JSCH -> Authentication succeeded (password).
JSCH -> 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 -> Disconnecting from 216.66.216.10 port 22
JSCH -> Disconnecting from 216.66.216.10 port 22
16:25:38,971 INFO (Connect thread 216.66.216.10 session) [SftpOperations] JSCH -> Caught an exception, leaving main loop due to socket closed
JSCH -> 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&fileName=testMsg.txt&password=******&strictHostKeyChecking=no&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&fileName=testMsg.txt&password=******&strictHostKeyChecking=no&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
私は同じコードを持っていますが、ラクダがなくても動作します。キャメルバージョンの何が問題になっていますか? また、サーバーが秘密鍵について尋ねないのはなぜですか?
アップデート:
秘密鍵を追加しようとしています:
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();
キーは読み取られましたが、エラーが発生しました:
com.jcraft.jsch.JSchException: invalid privatekey: POLP-FROAKS
at com.jcraft.jsch.IdentityFile.<init>(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)
キーは PuTTY で生成されました。FilleZilla は正常にキーを受け入れました。どうして????
更新:いいえ。キーに問題はありません。puttyge.exe->conversion で putty 形式のキーを openssh 形式に変換したところ、JSCH は正常に受け入れました。しかし、古いエラー「ディレクトリを...に変更できません」が戻ってきました...