Spring Integration / JSch:身份验证失败

2023-12-14

我正在尝试使用 Spring Integration 的 SFTP 入站通道适配器,但我被困在这里:

20:29:30,458 INFO  [com.jcraft.jsch] (task-scheduler-6) Connecting to deployment port 22
20:29:30,484 INFO  [com.jcraft.jsch] (task-scheduler-6) Connection established
20:29:30,514 INFO  [com.jcraft.jsch] (task-scheduler-6) Remote version string: SSH-2.0-OpenSSH_5.9p1 Debian-5ubuntu1
20:29:30,514 INFO  [com.jcraft.jsch] (task-scheduler-6) Local version string: SSH-2.0-JSCH-0.1.45
20:29:30,514 INFO  [com.jcraft.jsch] (task-scheduler-6) CheckCiphers: aes256-ctr,aes192-ctr,aes128-ctr,aes256-cbc,aes192-cbc,aes128-cbc,3des-ctr,arcfour,arcfour128,arcfour256
20:29:30,515 INFO  [com.jcraft.jsch] (task-scheduler-6) CheckKexes: diffie-hellman-group14-sha1
20:29:30,515 INFO  [com.jcraft.jsch] (task-scheduler-6) diffie-hellman-group14-sha1 is not available.
20:29:30,516 INFO  [com.jcraft.jsch] (task-scheduler-6) SSH_MSG_KEXINIT sent
20:29:30,537 INFO  [com.jcraft.jsch] (task-scheduler-6) SSH_MSG_KEXINIT received
20:29:30,538 INFO  [com.jcraft.jsch] (task-scheduler-6) kex: server->client aes128-ctr hmac-md5 none
20:29:30,538 INFO  [com.jcraft.jsch] (task-scheduler-6) kex: client->server aes128-ctr hmac-md5 none
20:29:30,540 INFO  [com.jcraft.jsch] (task-scheduler-6) SSH_MSG_KEXDH_INIT sent
20:29:30,540 INFO  [com.jcraft.jsch] (task-scheduler-6) expecting SSH_MSG_KEXDH_REPLY
20:29:30,572 INFO  [com.jcraft.jsch] (task-scheduler-6) ssh_rsa_verify: signature true
20:29:30,572 INFO  [com.jcraft.jsch] (task-scheduler-6) Host 'deployment' is known and mathces the RSA host key
20:29:30,573 INFO  [com.jcraft.jsch] (task-scheduler-6) SSH_MSG_NEWKEYS sent
20:29:30,573 INFO  [com.jcraft.jsch] (task-scheduler-6) SSH_MSG_NEWKEYS received
20:29:30,573 INFO  [com.jcraft.jsch] (task-scheduler-6) SSH_MSG_SERVICE_REQUEST sent
20:29:30,597 INFO  [com.jcraft.jsch] (task-scheduler-6) SSH_MSG_SERVICE_ACCEPT received
20:29:30,650 INFO  [com.jcraft.jsch] (task-scheduler-6) Authentications that can continue: publickey,keyboard-interactive,password
20:29:30,651 INFO  [com.jcraft.jsch] (task-scheduler-6) Next authentication method: publickey
20:29:30,678 INFO  [com.jcraft.jsch] (task-scheduler-6) Authentications that can continue: password
20:29:30,679 INFO  [com.jcraft.jsch] (task-scheduler-6) Next authentication method: password
20:29:30,679 INFO  [com.jcraft.jsch] (task-scheduler-6) Disconnecting from deployment port 22
20:29:30,679 DEBUG [org.springframework.integration.channel.PublishSubscribeChannel] (task-scheduler-6) preSend on channel 'errorChannel', message: [Payload=org.springframework.integration.MessagingException: Failed to obtain pooled item][Headers={timestamp=1366655370679, id=c6f7922d-d121-4f7e-b60c-5e1905960f5e}]
20:29:30,680 DEBUG [org.springframework.integration.handler.LoggingHandler] (task-scheduler-6) (inner bean)#24 received message: [Payload=org.springframework.integration.MessagingException: Failed to obtain pooled item][Headers={timestamp=1366655370679, id=c6f7922d-d121-4f7e-b60c-5e1905960f5e}]
20:29:30,681 ERROR [org.springframework.integration.handler.LoggingHandler] (task-scheduler-6) org.springframework.integration.MessagingException: Failed to obtain pooled item
    at org.springframework.integration.util.SimplePool.getItem(SimplePool.java:170)
    at org.springframework.integration.file.remote.session.CachingSessionFactory.getSession(CachingSessionFactory.java:83)
    at org.springframework.integration.file.remote.synchronizer.AbstractInboundFileSynchronizer.synchronizeToLocalDirectory(AbstractInboundFileSynchronizer.java:143)
    at org.springframework.integration.file.remote.synchronizer.AbstractInboundFileSynchronizingMessageSource.receive(AbstractInboundFileSynchronizingMessageSource.java:146)
    at org.springframework.integration.endpoint.SourcePollingChannelAdapter.receiveMessage(SourcePollingChannelAdapter.java:111)
    at org.springframework.integration.endpoint.AbstractTransactionSynchronizingPollingEndpoint.doPoll(AbstractTransactionSynchronizingPollingEndpoint.java:67)
    at org.springframework.integration.endpoint.AbstractPollingEndpoint$1.call(AbstractPollingEndpoint.java:146)
    at org.springframework.integration.endpoint.AbstractPollingEndpoint$1.call(AbstractPollingEndpoint.java:144)
    at org.springframework.integration.endpoint.AbstractPollingEndpoint$Poller$1.run(AbstractPollingEndpoint.java:236)
    at org.springframework.integration.util.ErrorHandlingTaskExecutor$1.run(ErrorHandlingTaskExecutor.java:52)
    at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:49)
    at org.springframework.integration.util.ErrorHandlingTaskExecutor.execute(ErrorHandlingTaskExecutor.java:49)
    at org.springframework.integration.endpoint.AbstractPollingEndpoint$Poller.run(AbstractPollingEndpoint.java:231)
    at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:53)
    at org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:81)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:98)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:206)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
    at java.lang.Thread.run(Thread.java:680)
Caused by: java.lang.IllegalStateException: failed to create SFTP Session
    at org.springframework.integration.sftp.session.DefaultSftpSessionFactory.getSession(DefaultSftpSessionFactory.java:266)
    at org.springframework.integration.file.remote.session.CachingSessionFactory$1.createForPool(CachingSessionFactory.java:55)
    at org.springframework.integration.file.remote.session.CachingSessionFactory$1.createForPool(CachingSessionFactory.java:53)
    at org.springframework.integration.util.SimplePool.doGetItem(SimplePool.java:180)
    at org.springframework.integration.util.SimplePool.getItem(SimplePool.java:160)
    ... 22 more
Caused by: java.lang.IllegalStateException: failed to connect
    at org.springframework.integration.sftp.session.SftpSession.connect(SftpSession.java:204)
    at org.springframework.integration.sftp.session.DefaultSftpSessionFactory.getSession(DefaultSftpSessionFactory.java:262)
    ... 26 more
Caused by: com.jcraft.jsch.JSchException: Auth cancel
    at com.jcraft.jsch.Session.connect(Session.java:463)
    at com.jcraft.jsch.Session.connect(Session.java:158)
    at org.springframework.integration.sftp.session.SftpSession.connect(SftpSession.java:196)
    ... 27 more

我绝对确定私钥是正确的,因为我可以这样做:

$ sftp web@deployment
Connected to deployment.
sftp> quit

我已将 ~/.ssh/id_rsa 复制到 ...path.../src/main/resources/keys/sftp_rsa。

这是我的配置:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:int="http://www.springframework.org/schema/integration"
       xmlns:int-sftp="http://www.springframework.org/schema/integration/sftp"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd

        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
        http://www.springframework.org/schema/integration/sftp http://www.springframework.org/schema/integration/sftp/spring-integration-sftp.xsd">

    <context:property-placeholder location="classpath:sftp.properties" ignore-resource-not-found="false"
                                  ignore-unresolvable="true"/>

    <bean id="sftpSessionFactory" class="org.springframework.integration.sftp.session.DefaultSftpSessionFactory">
        <property name="host" value="${sftp.host}"/>
        <property name="port" value="${sftp.port}"/>
        <property name="user" value="${sftp.username}"/>
        <property name="privateKey" value="${sftp.private_key_file}"/>
        <property name="privateKeyPassphrase" value="${sftp.private_key_passphrase}"/>
    </bean>

    <int-sftp:inbound-channel-adapter id="sftpInboundChannelAdapter"
                                      channel="receiveChannel"
                                      session-factory="sftpSessionFactory"
                                      local-directory="file:local-dir"
                                      remote-directory="${sftp.remote_directory}"
                                      auto-create-local-directory="true"
                                      delete-remote-files="false"
                                      filename-regex=".*">
        <int:poller fixed-rate="5000" max-messages-per-poll="1"/>
    </int-sftp:inbound-channel-adapter>

    <int:channel id="receiveChannel">
        <int:queue/>
    </int:channel>

</beans>

我的 sftp.properties 如下所示:

sftp.host=deployment
sftp.username=web
sftp.private_key_file=classpath:keys/sftp_rsa
sftp.private_key_passphrase=<censored>
sftp.remote_directory=/censored/path
sftp.port=22

我见过类似的条目但这没有帮助,因为我使用的是 Java 1.6 而不是 1.4。

有什么提示吗?


正如您引用的另一个问题中所讨论的,确凿的证据是......

20:29:30,650 INFO  [com.jcraft.jsch] (task-scheduler-6) Authentications that can continue: publickey,keyboard-interactive,password
20:29:30,651 INFO  [com.jcraft.jsch] (task-scheduler-6) Next authentication method: publickey
20:29:30,678 INFO  [com.jcraft.jsch] (task-scheduler-6) Authentications that can continue: password

pk授权失败;当它成功时,它不会退回到pw......

INFO: SSH_MSG_SERVICE_ACCEPT receivedINFO: Authentications that can continue: publickey,keyboard-interactive,password
INFO: Next authentication method: publickey
INFO: Authentication succeeded (publickey).

我刚刚运行了sftp 示例使用来自 github 的示例密钥文件并得到与您相同的结果;然后我复制了我的 id_rsa 文件(像你一样)并且它工作正常。如果您使用的是 eclipse,请务必按 F5(刷新)src/main/resources复制密钥文件后,否则它将不会在当前文件系统上使用该文件。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Spring Integration / JSch:身份验证失败 的相关文章

  • SSH.Net 异步文件下载

    我正在尝试使用 SSH NET 从 SFTP 服务器异步下载文件 如果我同步执行 它工作正常 但是当我异步执行时 我会得到空文件 这是我的代码 var port 22 string host localhost string usernam
  • 组在 RabbitMQ 中接收消息,最好使用 Spring AMQP?

    我正在从服务 S 接收消息 该服务将每个单独的属性更改作为单独的消息发布到实体 一个人为的例子是这样的实体 Person id 123 name Something address 如果姓名和地址在同一交易中更新 则 S 将发布两条消息 P
  • Camel SFTP - 无法将目录更改为“/”

    我需要通过 SFTP 连接到服务器 但收到此错误 INFO org apache camel component file remote SftpOperations connect Connected to sftp myserver c
  • Spring集成:如何顺序处理文件

    我使用 int file inbound channel adapter 来加载目录中存在的文件 我喜欢按顺序处理文件 这意味着当第一个文件的处理完成时 我加载第二个文件 等等 I see a sample https github com
  • Spring Integration SpEL 与注释有关的问题

    我的 fileMessageProvider 作为 InboundChannelAdapter value files poller Poller fixedDelay my poller interval maxMessagesPerPo
  • 如何从 WMQ 获取 JMS 目标

    我正在使用 spring 集成使用来自 wmq 的消息 但我无法在消息头中获取 JMS 目标 我想知道消费消息的队列名称 在活动 mq 中 我们将获得一个名为 JMS Destination 的参数 其中队列名称可用 是否有可能使用 spr
  • jsch ChannelExec 和 ChannelShell 之间的确切区别是什么?

    有人可以告诉我之间的区别吗ChannelExec ChannelShell shell 和 exec 通道 http sourceforge net apps mediawiki jsch index php title Shell Exe
  • 在jgit中配置known_hosts

    使用 jgit 和 gitolite 进行源代码控制 我有一个应用程序 可以根据命令生成某些代码 并且我们希望将其提交给源代码控制 目标是快速拉动 提交新代码 然后推送它 我有以下方法 private void commitToGitRep
  • Spring AMQP + RabbitMQ 3.3.5 ACCESS_REFUSED - 使用身份验证机制 PLAIN 拒绝登录

    我遇到以下异常 org springframework amqp AmqpAuthenticationException com rabbitmq client AuthenticationFailureException ACCESS R
  • rabbitmq 通道因 PRECONDITION_FAILED 关闭 - 快速回复消费者不存在

    当我们从 Spring Boot 服务向rabbitmq 发布消息时 出现以下错误 而且这是间歇性的 我们无法重现这一点 AMQP 连接 123 11 xxx xx 5672 错误 org springframework amqp rabb
  • eclipse sts 4 中没有集成图视图?

    甚至不再有创建 spring bean 配置文件的选项 从 3 9 过渡到 4 的过程中 大量功能消失了 如果是这样的话 似乎他们在 Eclipse 端为 IDE 不可知论牺牲了相当多 Spring Tools 4 不再包含对 Spring
  • 使用 ssh-keygen 创建 JSch 接受的 SSH 私钥 [重复]

    这个问题在这里已经有答案了 不是直接的编程问题 但有某种相关性 JSch Java SSH 库 似乎不允许 macOS 10 14 使用以下命令创建私钥 ssh keygen t rsa b 4096 我应该使用什么命令来创建具有这种格式的
  • 是否可以仅使用 T-SQL 命令而不是 SSIS 让 SQL Server 登录 SFTP 并上传文件?

    我有一个 SSIS 包 它可以登录到我客户端的 SFTP 站点并使用发送到 WinSCP 的命令上传文件 这个包经常失败并且很难使用 Visual Studio 崩溃如此频繁 以至于我的团队拒绝再使用它 我们正在将所有自动化任务迁移到存储过
  • Spring集成中运行时可配置的动态路由

    我想构建一个具有多个出站网关的方案 可以在运行时添加这些网关 假设它以 2 个网关开始 但能够在运行时添加第 3 4 个网关 我想要 http outbound gateways 来实现它们的功能 但想在运行时构建它们的实例 问题在于在 s
  • 将私钥作为字符串的 Java SFTP 客户端

    Apache Commons 和 JSch 都需要私钥文件来建立 SFTP 连接 我正在从事的项目将用于连接到多个 SFTP 服务器 因此 我们不希望部署多个私钥文件 而是将这些密钥作为字符串保存在加密的配置文件中 是否有不需要私钥文件对象
  • spring-integration并行分割路由聚合流由于单向MessageHandler而失败

    我想通过拆分项目 将每个项目路由到适当的网关并聚合结果来并行处理项目列表 但是 我的应用程序无法启动 出现以下错误 BeanCreationException The currentComponent is a one way Messag
  • Spring集成MQTT发布订阅多个主题

    我正在尝试构建一个订阅多个 mqtt 主题的应用程序 获取信息 处理它并形成 xml 并在处理时触发一个事件 以便这些可以发送到某个云服务器 并将成功的响应从那里发送回MQTT 通道
  • 我是否应该将 CachingConnectionFactory 与 hornetq 2.4.1 一起使用

    根据有关在 hornetq 中使用 JMSTemplate 的长期信息 我们在连接到服务器时一直使用 CachingConnectionFactory 这是一个示例配置 与我们正在使用的配置非常相似
  • Spring Batch - 读取多行日志消息

    我面临一个问题 在配置了 Spring 集成的 Spring Batch 应用程序中将多行日志消息读取为单个消息 该应用程序必须将多行日志消息 示例异常堆栈跟踪 读取为单个消息 稍后它必须处理并对消息进行分类以进一步建立索引 每行都由其时间
  • 使用 ChannelExec 的命令未执行 - Jsch

    我正在使用 Jsch 在服务器中创建一个文件并执行一些命令 对于文件创建 它工作正常 但是对于命令执行 则不然 它保持状态 1 仍在处理它 并永远保持该状态 这种情况发生在 shell 执行或我尝试成为 root 时 请按照以下方法操作 p

随机推荐