Ant ssh无法连接到计算机

时间:2015-04-23 07:38:26

标签: ant ssh jsch

我的ant build.xml通过ssh与另一台计算机的连接有问题。我的计算机有IP地址:10.62.11.40,我有一个蚂蚁代码连接这台电脑:

PSModulePath

它是“ant build.xml”命令的输出:

<available property="ant-jsch.present" file="${ant.home}/lib/ant-jsch.jar"/>
            <fail if="ant-jsch.present" message="Please remove ant-jsch.jar from ANT_HOME/lib see [http://ant.apache.org/faq.html#delegating-classloader]"/>

        <path id="jsch.path">
            <pathelement location="lib/ant-jsch.jar" />
            <pathelement location="lib/jsch-0.1.44.jar" />
        </path>

        <taskdef name="scp" classname="org.apache.tools.ant.taskdefs.optional.ssh.Scp" classpathref="jsch.path" />
        <taskdef name="sshexec" classname="org.apache.tools.ant.taskdefs.optional.ssh.SSHExec" classpathref="jsch.path" />

        <echo message="Start Working...123"/>
        <sshexec host="10.62.11.40" username="${username}" password="${password}" command='cmd /C mkdir "C:\\\\newFolder"' trust="true" failonerror="true" verbose="true"/>

通过普通终端正常工作与此计算机连接,我可以连接并在此计算机上执行某些操作。

  [sshexec] ssh_rsa_verify: signature true
  [sshexec] Permanently added '10.62.11.40' (RSA) to the list of known hosts.
  [sshexec] SSH_MSG_NEWKEYS sent
  [sshexec] SSH_MSG_NEWKEYS received
  [sshexec] SSH_MSG_SERVICE_REQUEST sent
  [sshexec] SSH_MSG_SERVICE_ACCEPT received
  [sshexec] Authentications that can continue: publickey,keyboard-interactive,pa
ssword
  [sshexec] Next authentication method: publickey
  [sshexec] Authentications that can continue: keyboard-interactive,password
  [sshexec] Next authentication method: keyboard-interactive
  [sshexec] Authentications that can continue: password
  [sshexec] Next authentication method: password
  [sshexec] Authentication succeeded (password).
  [sshexec] cmd : cmd /C mkdir "C:\\\\newFolder"
  [sshexec] Caught an exception, leaving main loop due to SSH_MSG_DISCONNECT: 2
fork failed: Resource temporarily unavailable
  [sshexec] Disconnecting from 10.62.11.40 port 22

BUILD FAILED
C:\isNowe\build.xml:11: The following error occurred while executing this line:
C:\isNowe\lib\macros\lib\is2k8.xml:36: Remote command failed with exit status -1

这一行是

'is2k8.xml:36' 

你能知道出了什么问题吗?

1 个答案:

答案 0 :(得分:0)

您已成功连接到远程主机,但远程命令失败:

cmd /C mkdir "C:\\\\newFolder"' 

您可以从命令行成功运行此命令吗?

添加-d标志以从Ant获取调试输出也可能有所帮助。