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