Ant scp task failure

自闭症网瘾萝莉.ら 提交于 2020-01-23 04:36:13

问题


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

  1. downloaded jsch-0.1.44.jar and copied to lib folder of Ant
  2. set the path and every thing

My buildfile is:

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

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?


回答1:


According to the Ant scp task docs, trust attribute:

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.

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.




回答2:


Be sure your ~/.ssh/known_hosts file is using un-hashed hostnames; if the lines start |1|base64data..., JSch appears unable to parse them. Create lines of the format hostname[,hostname|ip]* ssh-keytype base64data....

See man 8 sshd on the precise format of known_hosts, and tips on where to find the host's public key.



来源:https://stackoverflow.com/questions/6356212/ant-scp-task-failure

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!