You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

sshexec.html 4.8 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Language" content="en-us">
  4. <title>SSHEXEC Task</title>
  5. </head>
  6. <body>
  7. <h2><a name="sshexec">SSHEXEC</a></h2>
  8. <h3>Description</h3>
  9. <p><em>since Ant 1.6</em></p>
  10. <p>Runs a command on a remote machine running SSH daemon.
  11. </p>
  12. <p><b>Note:</b> This task depends on external libraries not included
  13. in the Ant distribution. See <a
  14. href="../install.html#librarydependencies">Library Dependencies</a>
  15. for more information. This task has been tested with jsch-0.1.3.</p>
  16. <h3>Parameters</h3>
  17. <table border="1" cellpadding="2" cellspacing="0">
  18. <tr>
  19. <td valign="top"><b>Attribute</b></td>
  20. <td valign="top"><b>Description</b></td>
  21. <td align="center" valign="top"><b>Required</b></td>
  22. </tr>
  23. <tr>
  24. <td valign="top">username</td>
  25. <td valign="top">The username on the remote host to which you are connecting.</td>
  26. <td valign="top" align="center">Yes</td>
  27. </tr>
  28. <tr>
  29. <td valign="top">command</td>
  30. <td valign="top">The command to run on the remote host.</td>
  31. <td valian="top" align="center">Yes</td>
  32. </tr>
  33. <tr>
  34. <td valign="top">port</td>
  35. <td valign="top">The port to connect to on the remote host.</td>
  36. <td valian="top" align="center">No, defaults to 22.</td>
  37. </tr>
  38. <tr>
  39. <td valign="top">trust</td>
  40. <td valign="top">This trusts all unknown hosts if set to yes/true.</td>
  41. <td valian="top" align="center">No, defaults to No.</td>
  42. </tr>
  43. <tr>
  44. <td valign="top">knownhosts</td>
  45. <td valign="top">This sets the known hosts file to use to validate
  46. the identity of the remote host. This must be a SSH2 format file.
  47. SSH1 format is not supported.</td>
  48. <td valian="top" align="center">No, defaults to
  49. ${user.home}/.ssh/known_hosts.</td>
  50. </tr>
  51. <tr>
  52. <td valign="top">failonerror</td>
  53. <td valign="top">Log a warning message, but do not stop the build,
  54. when the transfer does not work.
  55. </td>
  56. <td valign="top" align="center">No; defaults to true.</td>
  57. </tr>
  58. <tr>
  59. <td valign="top">password</td>
  60. <td valign="top">The password.</td>
  61. <td valign="top" align="center">Not if you are using key based
  62. authentication or the password has been given in the file or
  63. todir attribute.</td>
  64. </tr>
  65. <tr>
  66. <td valign="top">keyfile</td>
  67. <td valign="top">Location of the file holding the private key.</td>
  68. <td valign="top" align="center">Yes, if you are using key based
  69. authentication.</td>
  70. </tr>
  71. <tr>
  72. <td valign="top">passphrase</td>
  73. <td valign="top">Passphrase for your private key.</td>
  74. <td valign="top" align="center">No, defaults to an empty string.</td>
  75. </tr>
  76. <tr>
  77. <td valign="top">output</td>
  78. <td valign="top">Name of a file to which to write the output.</td>
  79. <td align="center" valign="top">No</td>
  80. </tr>
  81. <tr>
  82. <td valign="top">append</td>
  83. <td valign="top">Whether output file should be appended to or overwritten. Defaults to false, meaning overwrite any existing file.</td>
  84. <td align="center" valign="top">No</td>
  85. </tr>
  86. <tr>
  87. <td valign="top">outputproperty</td>
  88. <td valign="top">The name of a property in which the output of the
  89. command should be stored.</td>
  90. <td align="center" valign="top">No</td>
  91. </tr>
  92. <tr>
  93. <td valign="top">timeout</td>
  94. <td valign="top">Stop the command if it doesn't finish within the
  95. specified time (given in milliseconds). Defaults to 0 which means &quot;wait forever&quot;.</td>
  96. <td align="center" valign="top">No</td>
  97. </tr>
  98. </table>
  99. <h3>Examples</h3>
  100. <p><b>Run a command on a remote machine using password authentication</b></p>
  101. <pre>
  102. &lt;sshexec host=&quot;somehost&quot;
  103. username=&quot;dude&quot;
  104. password=&quot;yo&quot;
  105. command=&quot;touch somefile&quot;/&gt;
  106. </pre>
  107. <p><b>Run a command on a remote machine using key authentication</b></p>
  108. <pre>
  109. &lt;sshexec host=&quot;somehost&quot;
  110. username=&quot;dude&quot;
  111. keyfile=&quot;${user.home}/.ssh/id_dsa&quot;
  112. passphrase=&quot;yo its a secret&quot;
  113. command=&quot;touch somefile&quot;/&gt;
  114. </pre>
  115. <p><b>Run a command on a remote machine using key authentication with no passphrase</b></p>
  116. <pre>
  117. &lt;sshexec host=&quot;somehost&quot;
  118. username=&quot;dude&quot;
  119. keyfile=&quot;${user.home}/.ssh/id_dsa&quot;
  120. command=&quot;touch somefile&quot;/&gt;
  121. </pre>
  122. <p><strong>Security Note:</strong> Hard coding passwords and/or usernames
  123. in sshexec task can be a serious security hole. Consider using variable
  124. substituion and include the password on the command line. For example:<br>
  125. <pre>
  126. &lt;sshexec host=&quot;somehost&quot;
  127. username=&quot;${username}&quot;
  128. password=&quot;${password}&quot;
  129. command=&quot;touch somefile&quot;/&gt;
  130. </pre>
  131. Invoke ant with the following command line:
  132. <pre>
  133. ant -Dusername=me -Dpassword=mypassword target1 target2
  134. </pre>
  135. </p>
  136. <hr><p align="center">Copyright &copy; 2003 Apache Software Foundation.
  137. All rights Reserved.</p>
  138. </body>
  139. </html>