【问题标题】:Ant ssh can`t connect to computerAnt ssh 无法连接到计算机
【发布时间】:2015-07-01 05:51:29
【问题描述】:

我的 ant build.xml 通过 ssh 与另一台计算机连接时遇到问题。我有一台 IP 地址为:10.62.11.40 的计算机,我有一个 ant 代码可以连接这台计算机:

<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"/>

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

  [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' 

这一行是

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

你有什么问题吗?

【问题讨论】:

  • 你的服务器是什么? cygwin-ssh?

标签: ant ssh jsch


【解决方案1】:

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

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

你能从命令行成功运行这个命令吗?

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

【讨论】:

    猜你喜欢
    • 2019-05-16
    • 2020-08-29
    • 1970-01-01
    • 1970-01-01
    • 2019-04-27
    • 1970-01-01
    • 2018-06-04
    • 2018-12-11
    • 2012-03-25
    相关资源
    最近更新 更多