I ran into a problem where an ant scp task hangs during a fileset copy. The task is:
<scp file="${usr}:${pwd}@${hst}:${dir}/*" todir="${to}" trust="true"/>
It copies a number of files successfully and then hangs.
Note that the host that it’s copying from is localhost, but this should make no difference.
I’ve also used the same ant script to copy files from the same Linux host to a windows machine, and this works without any problems.
Google search reveals that there was a similar problem in around 2007, http://www.symphonious.net/2007/10/23/ant-scpssh-task-hangs-or-never-disconnects/, but the solution of upgrading to latest version of ant (or downgrading jsch) they give doesn’t fix the problem for me. (This defect is also metioned in https://issues.apache.org/bugzilla/show_bug.cgi?id=41090)
I’ve used ANT 1.8.2, ANT 1.7.1 and ANT 1.6.5 and they all have this problem.
I’m using jsch 0.1.44, but even with a later version of jsch I get this problem.
Any ideas?
Found a workaround that solves my problem. It’s to use sftp=”true” attribute of the scp task, like this: