I have one requirement: copy local files to remote system. I have done the following:
- downloaded jsch-0.1.44.jar and copied to lib folder of Ant
- 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?
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 formathostname[,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.According to the Ant
scp
task docs,trust
attribute: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 addtrust="true"
, or add the host to the knownhosts file.