sftp使用骆驼

时间:2012-12-17 09:20:31

标签: apache-camel

我正在尝试使用camel使用sftp,并获得jsch esception。 我为SFTP创建的路由 -

<camelContext xmlns="http://activemq.apache.org/camel/schema/spring">
    <package>myGroupId</package>
    <route>
      <from uri="file:src/srcData?noop=true"/>
      <choice>
        <when>
          <xpath>/person/city = 'London'</xpath>
          <to uri="file:src/targetData/UK"/>
        </when>
        <when>
          <xpath>/person/city = 'Chicago'</xpath>
          <to uri="file:src/targetData/US"/>
        </when>
        <when>
          <xpath>/person/city = 'Tokyo'</xpath>
          <to uri="sftp://XXXserverXXX:22/dir1/subdir?username=testUser?password=testPwd&amp;binary=true"/>
        </when>
        <otherwise>
          <to uri="file:src/targetData/OT"/>
        </otherwise>
      </choice>
    </route>
  </camelContext>

但是使用这种配置我面临以下异常 -   com.jcraft.jsch.JSchException:拒绝HostKey:

1 个答案:

答案 0 :(得分:4)

您应该定义一个主机文件: “knownHostsFile”选项应指向一个ssh已知主机文件,其中包含您要连接到的主机的公钥。

实际上是在这里记录的:http://camel.apache.org/ftp2.html