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 5.0 kB

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