java left logo
java middle logo
java right logo
 

Home arrow Other API Tips arrow Ant arrow How to use SshExec task
 
 
Main Menu
Home
Java Tutorials
Book Reviews
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Java Network
Java Forums
Java Blog




Most Visited Tips
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Book Reviews
Top Rated Tips
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Book Reviews


Statistics
Registered Users: 4085
Java SE Tips: 614
Java ME Tips: 202
Java EE Tips: 183
Other API Tips: 779
Java Applications: 298
Java Libraries: 209
Java Games: 16
Book Reviews:
 
 
 
How to use SshExec task E-mail
User Rating: / 13
PoorBest 

SshExec

Description

since Ant 1.6

Runs a command on a remote machine running SSH daemon.

Note: This task depends on external libraries not included in the Ant distribution. See Library Dependencies for more information. This task has been tested with jsch-0.1.7 to jsch-0.1.9 and won't work with versions of jsch earlier than 0.1.7.

Parameters

Attribute Description Required
host The hostname or IP address of the remote host to which you wish to connect. Yes
username The username on the remote host to which you are connecting. Yes
command The command to run on the remote host. Yes
port The port to connect to on the remote host. No, defaults to 22.
trust This trusts all unknown hosts if set to yes/true.
Note If you set this to false (the default), the host you connect to must be listed in your knownhosts file, this also implies that the file exists.
No, defaults to No.
knownhosts This sets the known hosts file to use to validate the identity of the remote host. This must be a SSH2 format file. SSH1 format is not supported. No, defaults to ${user.home}/.ssh/known_hosts.
failonerror Whether to halt the build if the command does not complete successfully. No; defaults to true.
password The password. Not if you are using key based authentication or the password has been given in the file or todir attribute.
keyfile Location of the file holding the private key. Yes, if you are using key based authentication.
passphrase Passphrase for your private key. No, defaults to an empty string.
output Name of a file to which to write the output. No
append Whether output file should be appended to or overwritten. Defaults to false, meaning overwrite any existing file. No
outputproperty The name of a property in which the output of the command should be stored. No
timeout Stop the command if it doesn't finish within the specified time (given in milliseconds). Defaults to 0 which means "wait forever". No

Examples

Run a command on a remote machine using password authentication

  <sshexec host="somehost"
	username="dude"

	password="yo"
	command="touch somefile"/>

Run a command on a remote machine using key authentication

  <sshexec host="somehost"

	username="dude"
	keyfile="${user.home}/.ssh/id_dsa"
	passphrase="yo its a secret"
	command="touch somefile"/>

Run a command on a remote machine using key authentication with no passphrase

  <sshexec host="somehost"
	username="dude"
	keyfile="${user.home}/.ssh/id_dsa"

	command="touch somefile"/>

Security Note: Hard coding passwords and/or usernames in sshexec task can be a serious security hole. Consider using variable substitution and include the password on the command line. For example:

  <sshexec host="somehost"
	username="${username}"

	password="${password}"
	command="touch somefile"/>
Invoke ant with the following command line:
    ant -Dusername=me -Dpassword=mypassword target1 target2

Source: Apache Ant


 Related Tips

 
< Prev   Next >

Page 1 of 0 ( 0 comments )

You can share your information about this topic using the form below!

Please do not post your questions with this form! Thanks.


Name (required)


E-Mail (required)

Your email will not be displayed on the site - only to our administrator
Homepage(optional)



Comment Enable HTML code : Yes No



 
       
         
     
 
 
 
   
 
 
java bottom left
java bottom middle
java bottom right
RSS 0.91 FeedRSS 1.0 FeedRSS 2.0 FeedATOM FeedOPML Feed

Home - About Us - Privacy Policy
Copyright 2005 - 2008 www.java-tips.org
Java is a trademark of Sun Microsystems, Inc.