Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ant scp task failure

Tags:

scp

ant

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?

like image 677
user617228 Avatar asked Jun 15 '11 10:06

user617228


2 Answers

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.

like image 182
martin clayton Avatar answered Sep 22 '22 16:09

martin clayton


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.

like image 28
Wyrframe Avatar answered Sep 21 '22 16:09

Wyrframe