Date: 2004-02-28T21:43:32
   Editor: 218.214.49.176 <>
   Wiki: Ant Wiki
   Page: NewAntFeaturesInDetail/Ssh
   URL: http://wiki.apache.org/ant/NewAntFeaturesInDetail/Ssh

   no comment

Change Log:

------------------------------------------------------------------------------
@@ -1,4 +1,4 @@
-manual pages of [http://ant.apache.org/manual-1.6beta/OptionalTasks/scp.html 
scp] and [http://ant.apache.org/manual-1.6beta/OptionalTasks/sshexec.html 
sshexec].
+manual pages of [http://ant.apache.org/manual/OptionalTasks/scp.html scp] and 
[http://ant.apache.org/manual/OptionalTasks/sshexec.html sshexec].
 
 So you want to deploy your distributables to a remote machine via scp?
 
@@ -6,38 +6,46 @@
 
 The task can be used very easily to copy a selection of files to a specific 
directory on the secured server.  The following example copies the files from 
the ${dist.dir} to a directory on a host built from a selection of properties:
 
-{{{ 
-{{{    &lt;scp todir="${username}:[EMAIL PROTECTED]:${hostpath}"&gt; }}}
-{{{        &lt;fileset dir="${dist.dir}"/&gt; }}}
-{{{    &lt;/scp&gt; }}}
- }}}
-
-A downfall to this task is that it will copy up every file every time, 
regardless of whether the original has changed or not.  This is of particular 
concern if you're deploying a large website or using a slow connection.  But 
don't fear the all new 
[http://ant.apache.org/manual-1.6beta/CoreTypes/selectors.html#modified 
<modified/>] selector can be used to cut out the unnecessary bandwidth.  The 
task now becomes:
-{{{ 
-{{{    &lt;scp todir="${username}:[EMAIL PROTECTED]:${hostpath}"&gt; }}}
-{{{        &lt;fileset dir="${dist.dir}"&gt; }}}
-{{{            &lt;modified&gt; }}}
-{{{                &lt;param name="cache" 
value="${build.dir}/deploy.cache"/&gt; }}}
-{{{            &lt;/modified&gt; }}}
-{{{        &lt;/fileset&gt; }}}
-{{{    &lt;/scp&gt; }}}
- }}}
-
-You might also want to consider using the Ant1.5 
[http://ant.apache.org/manual-1.6beta/CoreTasks/input.html <input/>] task so 
that users are prompted for configuration details if the properties haven't 
already been set.  A complete example follows:
-
-{{{ 
-{{{    &lt;target name="get-password" unless="password"&gt; }}}
-{{{        &lt;input message="Please enter password:" 
addproperty="password"/&gt; }}}
-{{{    &lt;/target&gt; }}}
-{{{     }}}
-{{{    &lt;target name="deploy" depends="get-password"&gt; }}}
-{{{        &lt;mkdir dir="${build.dir}"/&gt; }}}
-{{{        &lt;scp todir="${username}:[EMAIL PROTECTED]:${hostpath}"&gt; }}}
-{{{            &lt;fileset dir="${dist.dir}"&gt; }}}
-{{{                &lt;modified&gt; }}}
-{{{                    &lt;param name="cache" 
value="${build.dir}/deploy.cache"/&gt; }}}
-{{{                &lt;/modified&gt; }}}
-{{{            &lt;/fileset&gt; }}}
-{{{        &lt;/scp&gt; }}}
-{{{    &lt;/target&gt; }}}
- }}}
+{{{
+    <scp todir="${username}:[EMAIL PROTECTED]:${hostpath}">
+        <fileset dir="${dist.dir}"/>
+    </scp>
+}}}
+
+A downfall to this task is that it will copy up every file every time, 
regardless of whether the original has changed or not.  This is of particular 
concern if you're deploying a large website or using a slow connection.  But 
don't fear the all new 
[http://ant.apache.org/manual/CoreTypes/selectors.html#modified <modified/>] 
selector can be used to cut out the unnecessary bandwidth.  The task now 
becomes:
+{{{
+    <scp todir="${username}:[EMAIL PROTECTED]:${hostpath}">
+        <fileset dir="${dist.dir}">
+            <modified>
+                <param name="cache" value="${build.dir}/deploy.cache"/>
+            </modified>
+        </fileset>
+    </scp>
+}}}
+
+You might also want to consider using the Ant1.5 
[http://ant.apache.org/manual/CoreTasks/input.html <input/>] task so that users 
are prompted for configuration details if the properties haven't already been 
set.  A complete example follows:
+
+{{{
+    <target name="get-password" unless="password">
+        <input message="Please enter password:" addproperty="password"/>
+    </target>
+    
+    <target name="deploy" depends="get-password">
+        <mkdir dir="${build.dir}"/>
+        <scp todir="${username}:[EMAIL PROTECTED]:${hostpath}">
+            <fileset dir="${dist.dir}">
+                <modified>
+                    <param name="cache" value="${build.dir}/deploy.cache"/>
+                </modified>
+            </fileset>
+        </scp>
+    </target>
+}}}
+
+Don't forget to have a look at the `trust` and `knownhosts` attributes in the 
[http://ant.apache.org/manual/OptionalTasks/scp.html scp] task's description if 
you receive an exception like this:
+
+{{{
+    com.jcraft.jsch.JSchException: reject HostKey
+}}}
+
+Use `knownhosts` if you have a "known hosts" file containing the key of the 
host you want to connect to or `trust` if you don't have such a file and want 
to trust the host anyway.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to