Ant scp 任务失败 [英] Ant scp task failure
问题描述
我有一个要求:将本地文件复制到远程系统.我做了以下事情:
I have one requirement: copy local files to remote system. I have done the following:
- 下载 jsch-0.1.44.jar 并复制到 Ant 的 lib 文件夹
- 设置路径和一切
我的构建文件是:
<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?
推荐答案
根据 Antscp
task docs, trust
属性:
According to the Ant scp
task docs, trust
attribute:
这会信任所有未知主机(如果设置)是/真的.注意 如果您将此设置为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.
trust
属性未在您的任务调用中使用,因此主机 (10.184.74.168) 似乎不在您的 knownhosts 文件中.建议添加trust="true"
,或者将主机添加到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.
这篇关于Ant scp 任务失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!