SCP的Ant任务失败 [英] Ant scp task failure

查看:499
本文介绍了SCP的Ant任务失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个要求:本地文件复制到远程系统。
我也做了以下内容:

I have one requirement: copy local files to remote system. I have done the following:


  1. 下载jsch-0.1.44.jar并复制到Ant的lib文件夹

  2. 设置路径和每一件事

我的构建文件是:

<project name="ImportedBuild" default="all">
  <target name="copyFileToRemote">
    <echo>2222222222 copyFileToRemote Examples:::::::::::::</echo>
    <scp file="sample.txt" todir="${username}:${password}@${hostname}:/shared"/>
  </target>
</project>

当我运行Ant,我得到这个错误:

When I run Ant, I get this error:

BUILD FAILED com.jcraft.jsch.JSchException: reject HostKey: 10.184.74.168
    at com.jcraft.jsch.Session.checkHost(Session.java:712)
    at com.jcraft.jsch.Session.connect(Session.java:313)
    at com.jcraft.jsch.Session.connect(Session.java:154)
    at org.apache.tools.ant.taskdefs.optional.ssh.SSHBase.openSession(SSHBase.java:212)
    at org.apache.tools.ant.taskdefs.optional.ssh.Scp.upload(Scp.java:291)
    at org.apache.tools.ant.taskdefs.optional.ssh.Scp.execute(Scp.java:203)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
    ... etc ...

任何想法如何解决这个问题?

Any ideas how to resolve this?

推荐答案

按照蚂蚁 SCP 任务文档,信任属性:

这相信所有未知的主机如果设置
  为yes /真。注意:如果你将其设置为
  false(默认值),主机你
  连接必须先列出您
  knownhosts文件,这也意味着
  该文件存在。

This trusts all unknown hosts if set to yes/true. Note If you set this to false (the default), the host you connect to must be listed in your knownhosts file, this also implies that the file exists.

信任属性不是你的任务调用中使用,所以会出现主机(10.184.74.168)是不是在你的knownhosts文件。建议你添加信任=真正的,或将主机添加到knownhosts文件。

The trust attribute is not used in your task call, so it appears that the host (10.184.74.168) is not in your knownhosts file. Suggest you add trust="true", or add the host to the knownhosts file.

这篇关于SCP的Ant任务失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆