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