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.0 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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>Runs a command on a remote machine running SSH daemon.
  10. </p>
  11. <p><b>Note:</b> This task depends on external libraries not included
  12. in the Ant distribution. See <a
  13. href="../install.html#librarydependencies">Library Dependencies</a>
  14. for more information. This task has been tested with jsch-0.1.2.</p>
  15. <h3>Parameters</h3>
  16. <table border="1" cellpadding="2" cellspacing="0">
  17. <tr>
  18. <td valign="top"><b>Attribute</b></td>
  19. <td valign="top"><b>Description</b></td>
  20. <td align="center" valign="top"><b>Required</b></td>
  21. </tr>
  22. <tr>
  23. <td valign="top">username</td>
  24. <td valign="top">The username on the remote host to which you are connecting.</td>
  25. <td valign="top" align="center">Yes</td>
  26. </tr>
  27. <tr>
  28. <td valign="top">command</td>
  29. <td valign="top">The command to run on the remote host.</td>
  30. <td valian="top" align="center">Yes</td>
  31. </tr>
  32. <tr>
  33. <td valign="top">port</td>
  34. <td valign="top">The port to connect to on the remote host.</td>
  35. <td valian="top" align="center">No, defaults to 22.</td>
  36. </tr>
  37. <tr>
  38. <td valign="top">trust</td>
  39. <td valign="top">This trusts all unknown hosts if set to yes/true.</td>
  40. <td valian="top" align="center">No, defaults to No.</td>
  41. </tr>
  42. <tr>
  43. <td valign="top">knownhosts</td>
  44. <td valign="top">This sets the known hosts file to use to validate
  45. the identity of the remote host. This must be a SSH2 format file.
  46. SSH1 format is not supported.</td>
  47. <td valian="top" align="center">No, defaults to
  48. ${user.home}/.ssh/known_hosts.</td>
  49. </tr>
  50. <tr>
  51. <td valign="top">failonerror</td>
  52. <td valign="top">Log a warning message, but do not stop the build,
  53. when the transfer does not work.
  54. </td>
  55. <td valign="top" align="center">No; defaults to true.</td>
  56. </tr>
  57. <tr>
  58. <td valign="top">password</td>
  59. <td valign="top">The password.</td>
  60. <td valign="top" align="center">Not if you are using key based
  61. authentication or the password has been given in the file or
  62. todir attribute.</td>
  63. </tr>
  64. <tr>
  65. <td valign="top">keyfile</td>
  66. <td valign="top">Location of the file holding the private key.</td>
  67. <td valign="top" align="center">Yes, if you are using key based
  68. authentication.</td>
  69. </tr>
  70. <tr>
  71. <td valign="top">passphrase</td>
  72. <td valign="top">Passphrase for your private key.</td>
  73. <td valign="top" align="center">No, defaults to an empty string.</td>
  74. </tr>
  75. </table>
  76. <h3>Examples</h3>
  77. <p><b>Run a command on a remote machine using password authentication</b></p>
  78. <pre>
  79. &lt;sshexec host=&quot;somehost&quot;
  80. username=&quot;dude&quot;
  81. password=&quot;yo&quot;
  82. command=&quot;touch somefile&quot;/&gt;
  83. </pre>
  84. <p><b>Run a command on a remote machine using key authentication</b></p>
  85. <pre>
  86. &lt;sshexec host=&quot;somehost&quot;
  87. username=&quot;dude&quot;
  88. keyfile=&quot;${user.home}/.ssh/id_dsa&quot;
  89. passphrase=&quot;yo its a secret&quot;
  90. command=&quot;touch somefile&quot;/&gt;
  91. </pre>
  92. <p><b>Run a command on a remote machine using key authentication with no passphrase</b></p>
  93. <pre>
  94. &lt;sshexec host=&quot;somehost&quot;
  95. username=&quot;dude&quot;
  96. keyfile=&quot;${user.home}/.ssh/id_dsa&quot;
  97. command=&quot;touch somefile&quot;/&gt;
  98. </pre>
  99. <p><strong>Security Note:</strong> Hard coding passwords and/or usernames
  100. in sshexec task can be a serious security hole. Consider using variable
  101. substituion and include the password on the command line. For example:<br>
  102. <pre>
  103. &lt;sshexec host=&quot;somehost&quot;
  104. username=&quot;${username}&quot;
  105. password=&quot;${password}&quot;
  106. command=&quot;touch somefile&quot;/&gt;
  107. </pre>
  108. Invoke ant with the following command line:
  109. <pre>
  110. ant -Dusername=me -Dpassword=mypassword target1 target2
  111. </pre>
  112. </p>
  113. <hr><p align="center">Copyright &copy; 2003 Apache Software Foundation.
  114. All rights Reserved.</p>
  115. </body>
  116. </html>