public class SSHExecute extends Object
Constructor and Description |
---|
SSHExecute()
Creates a new execute object using
PumpStreamHandler for stream handling. |
SSHExecute(org.apache.tools.ant.taskdefs.ExecuteStreamHandler streamHandler)
Creates a new ssh object.
|
Modifier and Type | Method and Description |
---|---|
static void |
closeStreams(com.jcraft.jsch.ChannelExec process)
Close the streams belonging to the given Process.
|
int |
execute(String command)
Execute the command on the remote host.
|
protected com.jcraft.jsch.Session |
openSession()
Open an ssh seession.
|
void |
setHost(String host)
Remote host, either DNS name or IP.
|
void |
setKeyfile(String keyfile)
Sets the keyfile for the user.
|
void |
setKnownhosts(String knownHosts)
Sets the path to the file that has the identities of all known hosts.
|
void |
setPassphrase(String passphrase)
Sets the passphrase for the users key.
|
void |
setPassword(String password)
Sets the password for the user.
|
void |
setPort(int port)
Changes the port used to connect to the remote host.
|
void |
setProject(org.apache.tools.ant.Project project)
Used for logging
|
void |
setStreamHandler(org.apache.tools.ant.taskdefs.ExecuteStreamHandler streamHandler)
Set the stream handler to use.
|
void |
setTimeout(long timeout)
The connection can be dropped after a specified number of milliseconds.
|
void |
setTrust(boolean yesOrNo)
Setting this to true trusts hosts whose identity is unknown.
|
void |
setUsername(String username)
Username known to remote host.
|
public SSHExecute()
PumpStreamHandler
for stream handling.public SSHExecute(org.apache.tools.ant.taskdefs.ExecuteStreamHandler streamHandler)
streamHandler
- the stream handler used to handle the input and output streams of the subprocess.public void setStreamHandler(org.apache.tools.ant.taskdefs.ExecuteStreamHandler streamHandler)
streamHandler
- ExecuteStreamHandler.public void setTrust(boolean yesOrNo)
yesOrNo
- if true trust the identity of unknown hosts.public void setProject(org.apache.tools.ant.Project project)
public void setUsername(String username)
username
- The new username valuepublic void setPassword(String password)
password
- The new password valuepublic void setKeyfile(String keyfile)
keyfile
- The new keyfile valuepublic void setPassphrase(String passphrase)
passphrase
- The new passphrase valuepublic void setHost(String host)
host
- The new host valuepublic void setPort(int port)
port
- port number of remote host.public void setTimeout(long timeout)
timeout
- The new timeout value in secondspublic void setKnownhosts(String knownHosts)
knownHosts
- a path to the known hosts file.public int execute(String command) throws org.apache.tools.ant.BuildException, com.jcraft.jsch.JSchException, IOException, TimeoutException
command
- - what to execute on the remote host.org.apache.tools.ant.BuildException
- bad parameter.com.jcraft.jsch.JSchException
- if there's an underlying problem exposed in SSHIOException
- if there's a problem attaching streams.TimeoutException
- if we exceeded our timeoutprotected com.jcraft.jsch.Session openSession() throws com.jcraft.jsch.JSchException
com.jcraft.jsch.JSchException
- on errorpublic static void closeStreams(com.jcraft.jsch.ChannelExec process) throws IOException
process
- the Process
.IOException
Copyright © 2009-2012 jclouds. All Rights Reserved.