Apache Camel SFTP:方法“publickey,gssapi-keyex,gssapi-with-mic,password”的身份验证取消

2nc8po8w  于 9个月前  发布在  Apache
关注(0)|答案(1)|浏览(157)

我试图连接一个SFTP服务器与私钥,但我得到这个错误。(私钥适用于WinSCP和Filezilla)

org.apache.camel.component.file.GenericFileOperationFailedException: Cannot connect to sftp://xxxxx@xxxx:22
    at org.apache.camel.component.file.remote.SftpOperations.connect(SftpOperations.java:138) ~[camel-ftp-4.0.1.jar:4.0.1]
    at org.apache.camel.component.file.remote.RemoteFileConsumer.connectIfNecessary(RemoteFileConsumer.java:230) ~[camel-ftp-4.0.1.jar:4.0.1]
    at org.apache.camel.component.file.remote.RemoteFileConsumer.prePollCheck(RemoteFileConsumer.java:75) ~[camel-ftp-4.0.1.jar:4.0.1]
    at org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:126) ~[camel-file-4.0.1.jar:4.0.1]
    at org.apache.camel.support.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:203) ~[camel-support-4.0.1.jar:4.0.1]
    at org.apache.camel.support.ScheduledPollConsumer.run(ScheduledPollConsumer.java:117) ~[camel-support-4.0.1.jar:4.0.1]
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) ~[na:na]
    at java.base/java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305) ~[na:na]
    at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305) ~[na:na]
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[na:na]
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[na:na]
    at java.base/java.lang.Thread.run(Thread.java:833) ~[na:na]
Caused by: com.jcraft.jsch.JSchException: Auth cancel for methods 'publickey,gssapi-keyex,gssapi-with-mic,password'
    at com.jcraft.jsch.Session.connect(Session.java:499) ~[jsch-0.2.11.jar:0.2.11]
    at org.apache.camel.component.file.remote.SftpOperations.tryConnect(SftpOperations.java:161) ~[camel-ftp-4.0.1.jar:4.0.1]
    at org.apache.camel.support.task.BlockingTask.lambda$run$0(BlockingTask.java:40) ~[camel-support-4.0.1.jar:4.0.1]
    at org.apache.camel.support.task.ForegroundTask.run(ForegroundTask.java:94) ~[camel-support-4.0.1.jar:4.0.1]
    at org.apache.camel.support.task.BlockingTask.run(BlockingTask.java:40) ~[camel-support-4.0.1.jar:4.0.1]
    at org.apache.camel.component.file.remote.SftpOperations.connect(SftpOperations.java:136) ~[camel-ftp-4.0.1.jar:4.0.1]
    ... 11 common frames omitted

我尝试了两个SFTP服务器,我可以连接一个相同配置的服务器。这是我的SFTP路由器;

JSch.setConfig("server_host_key", JSch.getConfig("server_host_key") + ",ssh-dss");
JSch.setConfig("PubkeyAcceptedAlgorithms", JSch.getConfig("PubkeyAcceptedAlgorithms") + ",ssh-rsa");
JSch.setConfig("kex", JSch.getConfig("kex") + "diffie-hellman-group1-sha1,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group-exchange-sha256");
        
byte[] privateKeyBytes = Base64.decodeBase64("base64_key");
getContext().getRegistry().bind("senderPrivateKeyArrRegistry", privateKeyBytes);

from("sftp://xxxxx@xxxxx:22//?username=xxxxx&throwExceptionOnConnectFailed=true&privateKeyPassphrase=xxxxxx&privateKey=#senderPrivateKeyArrRegistry&minDepth=1&recursive=false&antInclude=xxx&exclude=&sortBy=file:modified&noop=true&maximumReconnectAttempts=0&disconnect=true")
.process(exchange -> {
    System.out.println(exchange.getIn().getBody());
});

我试着用“com.github.mwiede”改变Jsch库,但没有成功。我也尝试添加“preferredAuthentications=publickey”路由,但同样的错误。
Camel 版:4.0.1

Connection established
Remote version string: SSH-2.0-OpenSSH_8.0
Local version string: SSH-2.0-JSCH_0.2.11
CheckCiphers: [email protected]
CheckKexes: curve25519-sha256,[email protected],curve448-sha512
CheckSignatures: ssh-ed25519,ssh-ed448
SSH_MSG_KEXINIT sent
SSH_MSG_KEXINIT received
server proposal: KEX algorithms: curve25519-sha256,[email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1
server proposal: host key algorithms: rsa-sha2-512,rsa-sha2-256,ssh-rsa,ecdsa-sha2-nistp256,ssh-ed25519
server proposal: ciphers c2s: [email protected],[email protected],aes256-ctr,aes256-cbc,[email protected],aes128-ctr,aes128-cbc
server proposal: ciphers s2c: [email protected],[email protected],aes256-ctr,aes256-cbc,[email protected],aes128-ctr,aes128-cbc
server proposal: MACs c2s: [email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha1,[email protected],hmac-sha2-512
server proposal: MACs s2c: [email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha1,[email protected],hmac-sha2-512
server proposal: compression c2s: none,[email protected]
server proposal: compression s2c: none,[email protected]
server proposal: languages c2s: 
server proposal: languages s2c: 
client proposal: KEX algorithms: curve25519-sha256,[email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha256diffie-hellman-group1-sha1,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group-exchange-sha256,ext-info-c
client proposal: host key algorithms: ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,rsa-sha2-512,rsa-sha2-256,ssh-rsa
client proposal: ciphers c2s: aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected]
client proposal: ciphers s2c: aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected]
client proposal: MACs c2s: [email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1
client proposal: MACs s2c: [email protected],hmac-sh[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1
client proposal: compression c2s: none
client proposal: compression s2c: none
client proposal: languages c2s: 
client proposal: languages s2c: 
kex: algorithm: curve25519-sha256
kex: host key algorithm: ssh-ed25519
kex: server->client cipher: aes128-ctr MAC: [email protected] compression: none
kex: client->server cipher: aes128-ctr MAC: [email protected] compression: none
SSH_MSG_KEX_ECDH_INIT sent
expecting SSH_MSG_KEX_ECDH_REPLY
ssh_eddsa_verify: ssh-ed25519 signature true
Host 'xyz123.com' is known and matches the EDDSA host key
SSH_MSG_NEWKEYS sent
SSH_MSG_NEWKEYS received
SSH_MSG_SERVICE_REQUEST sent
SSH_MSG_EXT_INFO received
server-sig-algs=<ssh-ed25519,ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521>
SSH_MSG_SERVICE_ACCEPT received
Authentications that can continue: publickey,password
Next authentication method: publickey
Authentications that can continue: password
Next authentication method: password
Login trials exceeds 0
Disconnecting from xyz123.com port 22
a9wyjsp7

a9wyjsp71#

我发现问题了。此问题是由用于passPhrase的值包含不适当的字符引起的。
如果您按如下方式配置端点,则此问题将得到解决。

....&privateKeyPassphrase=RAW("+passphrase+").to(...)

相关问题