You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by "Anderson, Rob H - VSCM" <An...@vectorscm.com> on 2003/03/21 17:45:45 UTC

RE: SSH in ANT?!?! (WAS: RE: process on a remote server via an AN T ?????)

If you use the sshexec task you do not need to have an ssh client on your
local machine. Obviously, the remote machine needs to be running sshd.

<sshexec host="somehost"
	username="dude"
	keyfile="${user.home}/.ssh/id_dsa"
	passphrase="yo its a secret"
	command="./remotesctipt.sh"/>

If you want to execute an ant script on the remote machine you will need to
install ant and the scripts on the remote machine. Then run a task like the
following

<sshexec host="somehost"
	username="dude"
	keyfile="${user.home}/.ssh/id_dsa"
	passphrase="yo its a secret"
	command="cd path/to/build/file ; ant targetname"/>

I hope this helps.

-Rob Anderson

-----Original Message-----
From: peter reilly [mailto:peter.reilly@corvil.com]
Sent: Friday, March 21, 2003 3:25 AM
To: Ant Users List
Subject: Re: SSH in ANT?!?! (WAS: RE: process on a remote server via an
ANT ?????)


I do not have windows at the moment so take what
I am saying with a grain of salt.

The question is not really an ant question. So
test everything at the command line first.

I assume that there is a ssh deamon/service running on
the remote machine and there is a ssh command line
utility in your exec path.

If the sshd on the remote machine is a the cygwin sshd
and you have cygwin installed correctly on both machines
the script should work as is.

If cygwin sshd is installed on the remote machine but the
local machine does not have cygwin but does have another
ssh client cli program that can run in a bat file one can do

<shellscript shell="cmd.exe" tmpsuffix=".bat">
    <arg value="/c"/>
     <arg value="call">
      ssh ${server} ./script.sh
</shellscript>

Other combinations you need to try yourself.

Important to note that the ./script.sh is a file on the remote machine.

To run a script defined in the ant build file do:

<shellscript shell="sh">
    ssh ${server} <<END
cd /tmp
ls -lrta
END
  </shellscript>

On Friday 21 March 2003 10:46, Samuel Blanchet wrote:
> Is it possible to run this script beetween two Windows machines ???
>
> -----Message d'origine-----
> De : peter reilly [mailto:peter.reilly@corvil.com]
> Envoyé : vendredi 21 mars 2003 09:43
> À : Ant Users List
> Objet : Re: SSH in ANT?!?! (WAS: RE: process on a remote server via an
> ANT ?????)
>
>
> Or use <shellscript> in ant-contrib cvs head
>
> <property name="server" value="serv1"/>
> <shellscript shell="sh">
>     ssh ${server} ./script.sh
> </shellscript>
>
> Peter
>
> On Friday 21 March 2003 08:27, shahaji.kadam@orbitech.co.in wrote:
> > use <telnet> task.
> >
> > <telnet userid="userid" password="pwd" server="server">
> >    <read>/users/userid</read>
> >    <write>./script.sh</write>
> >    <read string="/users/userid"/>
> > </telnet>
> >
> > this will require additional component, NetComponents.jar, in CLASSPATH.
> > see docs.
> >
> > -----Original Message-----
> > From: sblanchet [mailto:sblanchet@sopragroup.com]
> > Sent: Friday,March 21, 2003 1:43 PM
> > To: user
> > Cc: sblanchet
> > Subject: RE: SSH in ANT?!?! (WAS: RE: process on a remote server via an
> > ANT ?????)
> >
> >
> >
> > Hi,
> >
> > Is there somebody who can send me a sample script to execute an ant
> > script on a remote machine (with telnet and ssh) ?
> > Thanks a lot
> >
> > Sam
> >
> >
> > -----Message d'origine-----
> > De : Nathan Christiansen [mailto:Nathan_Christiansen@tni.com]
> > Envoyé : jeudi 20 mars 2003 20:40
> > À : Ant Users List
> > Objet : RE: SSH in ANT?!?! (WAS: RE: process on a remote server via an
> > ANT ?????)
> >
> >
> > I was unaware that other JCE implementations were available, I just
> > blindly trusted the JSch website (http://www.jcraft.com/jsch/)
> >
> > Lesson learned: Never underestimate the resourcefulness of an open
> > source hacker. :)
> >
> > -- Nathan Christiansen
> >    Tahitian Noni International
> >    http://www.tahitiannoni.com
> >
> >
> > -----Original Message-----
> > From: Stefan Bodewig [mailto:bodewig@apache.org]
> > Sent: Thursday, March 20, 2003 9:47 AM
> > To: user@ant.apache.org
> > Subject: Re: SSH in ANT?!?! (WAS: RE: process on a remote server via an
> > ANT ?????)
> >
> >
> > On Thu, 20 Mar 2003, Nathan Christiansen <Na...@tni.com>
> >
> > wrote:
> > > It is also important to note that since JSch uses the JCE (Java
> > > Cryptography Extension)
> >
> > True.
> >
> > > it REQUIRES the use of JDK 1.4 or above.
> >
> > No.  1.2.2 and Bouncycastle's JCE work fine for me.
> >
> > Stefan
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> > For additional commands, e-mail: user-help@ant.apache.org
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> > For additional commands, e-mail: user-help@ant.apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org

Re: SSH in ANT?!?! (WAS: RE: process on a remote server via an AN T ?????)

Posted by peter reilly <pe...@corvil.com>.
It is of course a lot better to use <sshexec/> than <shellscript/>
for this.

Also my example contained an error, it should be
 <shellscript shell="sh"><![CDATA[
     ssh ${server} <<END
 cd /tmp
 ls -lrta
 END
 ]]></shellscript>

Peter.
On Friday 21 March 2003 16:45, Anderson, Rob H - VSCM wrote:
> If you use the sshexec task you do not need to have an ssh client on your
> local machine. Obviously, the remote machine needs to be running sshd.
>
> <sshexec host="somehost"
> 	username="dude"
> 	keyfile="${user.home}/.ssh/id_dsa"
> 	passphrase="yo its a secret"
> 	command="./remotesctipt.sh"/>
>
> If you want to execute an ant script on the remote machine you will need to
> install ant and the scripts on the remote machine. Then run a task like the
> following
>
> <sshexec host="somehost"
> 	username="dude"
> 	keyfile="${user.home}/.ssh/id_dsa"
> 	passphrase="yo its a secret"
> 	command="cd path/to/build/file ; ant targetname"/>
>
> I hope this helps.
>
> -Rob Anderson
>
> -----Original Message-----
> From: peter reilly [mailto:peter.reilly@corvil.com]
> Sent: Friday, March 21, 2003 3:25 AM
> To: Ant Users List
> Subject: Re: SSH in ANT?!?! (WAS: RE: process on a remote server via an
> ANT ?????)
>
>
> I do not have windows at the moment so take what
> I am saying with a grain of salt.
>
> The question is not really an ant question. So
> test everything at the command line first.
>
> I assume that there is a ssh deamon/service running on
> the remote machine and there is a ssh command line
> utility in your exec path.
>
> If the sshd on the remote machine is a the cygwin sshd
> and you have cygwin installed correctly on both machines
> the script should work as is.
>
> If cygwin sshd is installed on the remote machine but the
> local machine does not have cygwin but does have another
> ssh client cli program that can run in a bat file one can do
>
> <shellscript shell="cmd.exe" tmpsuffix=".bat">
>     <arg value="/c"/>
>      <arg value="call">
>       ssh ${server} ./script.sh
> </shellscript>
>
> Other combinations you need to try yourself.
>
> Important to note that the ./script.sh is a file on the remote machine.
>
> To run a script defined in the ant build file do:
>
> <shellscript shell="sh">
>     ssh ${server} <<END
> cd /tmp
> ls -lrta
> END
>   </shellscript>
>
> On Friday 21 March 2003 10:46, Samuel Blanchet wrote:
> > Is it possible to run this script beetween two Windows machines ???
> >
> > -----Message d'origine-----
> > De : peter reilly [mailto:peter.reilly@corvil.com]
> > Envoyé : vendredi 21 mars 2003 09:43
> > À : Ant Users List
> > Objet : Re: SSH in ANT?!?! (WAS: RE: process on a remote server via an
> > ANT ?????)
> >
> >
> > Or use <shellscript> in ant-contrib cvs head
> >
> > <property name="server" value="serv1"/>
> > <shellscript shell="sh">
> >     ssh ${server} ./script.sh
> > </shellscript>
> >
> > Peter
> >
> > On Friday 21 March 2003 08:27, shahaji.kadam@orbitech.co.in wrote:
> > > use <telnet> task.
> > >
> > > <telnet userid="userid" password="pwd" server="server">
> > >    <read>/users/userid</read>
> > >    <write>./script.sh</write>
> > >    <read string="/users/userid"/>
> > > </telnet>
> > >
> > > this will require additional component, NetComponents.jar, in
> > > CLASSPATH. see docs.
> > >
> > > -----Original Message-----
> > > From: sblanchet [mailto:sblanchet@sopragroup.com]
> > > Sent: Friday,March 21, 2003 1:43 PM
> > > To: user
> > > Cc: sblanchet
> > > Subject: RE: SSH in ANT?!?! (WAS: RE: process on a remote server via an
> > > ANT ?????)
> > >
> > >
> > >
> > > Hi,
> > >
> > > Is there somebody who can send me a sample script to execute an ant
> > > script on a remote machine (with telnet and ssh) ?
> > > Thanks a lot
> > >
> > > Sam
> > >
> > >
> > > -----Message d'origine-----
> > > De : Nathan Christiansen [mailto:Nathan_Christiansen@tni.com]
> > > Envoyé : jeudi 20 mars 2003 20:40
> > > À : Ant Users List
> > > Objet : RE: SSH in ANT?!?! (WAS: RE: process on a remote server via an
> > > ANT ?????)
> > >
> > >
> > > I was unaware that other JCE implementations were available, I just
> > > blindly trusted the JSch website (http://www.jcraft.com/jsch/)
> > >
> > > Lesson learned: Never underestimate the resourcefulness of an open
> > > source hacker. :)
> > >
> > > -- Nathan Christiansen
> > >    Tahitian Noni International
> > >    http://www.tahitiannoni.com
> > >
> > >
> > > -----Original Message-----
> > > From: Stefan Bodewig [mailto:bodewig@apache.org]
> > > Sent: Thursday, March 20, 2003 9:47 AM
> > > To: user@ant.apache.org
> > > Subject: Re: SSH in ANT?!?! (WAS: RE: process on a remote server via an
> > > ANT ?????)
> > >
> > >
> > > On Thu, 20 Mar 2003, Nathan Christiansen <Na...@tni.com>
> > >
> > > wrote:
> > > > It is also important to note that since JSch uses the JCE (Java
> > > > Cryptography Extension)
> > >
> > > True.
> > >
> > > > it REQUIRES the use of JDK 1.4 or above.
> > >
> > > No.  1.2.2 and Bouncycastle's JCE work fine for me.
> > >
> > > Stefan
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> > > For additional commands, e-mail: user-help@ant.apache.org
> > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> > > For additional commands, e-mail: user-help@ant.apache.org
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> > For additional commands, e-mail: user-help@ant.apache.org
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> > For additional commands, e-mail: user-help@ant.apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org