public class GsiSshExec extends RemoteExec
To create a gsissh session the code needs a valid proxy certificate and a valid CA certificate/ trusted certificate for the server. The code searches for the proxy certificates and CA certificates at default locations based on the specifications of underlying jglobus package -- http://www-unix.globus.org/cog/distribution/1.6.0/docs/configuring.html By default it looks for proxy certificates in the system's temp directory and for CA certificates(trusted certificates) in ${user.home}/.globus/certificates and /etc/grid-security/certificates. You can alter the default file and search path by creating appropriate entries in $HOME/.globus/cog.properties. Please refer to http://www-unix.globus.org/cog/distribution/1.6.0/docs/configuring.html for more configuration details.
You can create several sessions to different sites and use any of them referring to it with its user@host:port. If port is not specified defaults to 2222. Once instantiated the GsiSsh object can be used by anyone anytime to copy file or execute commands without authenticating again.
Modifier and Type | Field and Description |
---|---|
protected com.sshtools.j2ssh.configuration.SshConnectionProperties |
connectionProfile |
protected com.sshtools.j2ssh.SshClient |
sshClient |
Constructor and Description |
---|
GsiSshExec(java.lang.String target) |
GsiSshExec(java.lang.String user,
java.lang.String host) |
GsiSshExec(java.lang.String user,
java.lang.String host,
int port) |
Modifier and Type | Method and Description |
---|---|
protected int |
_copyTo(java.io.File lfile,
java.lang.String targetPath,
boolean recursive)
Copy _one_ local file to a remote directory Input: file of type File
(which can be a directory) Input must not have wildcards. targetPath is
either a directory or filename
|
void |
addIdentity(java.lang.String identity)
addIdentity, useless for local exec
|
boolean |
authenticate(boolean externalkeyx) |
void |
closeConnection() |
int |
copyFrom(java.lang.String sourcePath,
java.io.File localPath,
boolean recursive)
Copy a local/remote file into a local file Input: 'sourcePath' of type
String (can be a directory or filename) 'localPath' is either a directory
or filename Only if 'recursive' is set, will directories copied
recursively.
|
int |
executeCmd(java.lang.String command,
java.io.OutputStream streamOut,
java.io.OutputStream streamErr)
Execute a command externally.
|
int |
executeCmd(java.lang.String command,
java.io.OutputStream streamOut,
java.io.OutputStream streamErr,
java.lang.String thirdPartyTarget)
Execute a command externally where the command connects to a third party
and needs to authenticate to that third party.
|
java.util.List |
getAvailableAuthMethods() |
boolean |
getForcedCleanUp() |
int |
getTimeout() |
boolean |
openConnection() |
boolean |
openConnection(boolean authenticate) |
void |
setForcedCleanUp(boolean forcedCleanUp)
Specify if killing of external processes (i.e. clean-up) after error or
timeout is required.
|
void |
setPortForwardingL(java.lang.String spec)
port forwarding not working on local exec
|
void |
setPortForwardingR(java.lang.String spec)
port forwarding not working on local exec
|
void |
setTimeout(int seconds)
Set timeout for the operations.
|
void |
setTimeout(int seconds,
boolean stdout,
boolean stderr)
Set timeout for the operations.
|
copyFrom, copyTo, copyTo, createDir, deleteFile, kill
protected com.sshtools.j2ssh.SshClient sshClient
protected com.sshtools.j2ssh.configuration.SshConnectionProperties connectionProfile
public GsiSshExec(java.lang.String user, java.lang.String host)
public GsiSshExec(java.lang.String user, java.lang.String host, int port)
public GsiSshExec(java.lang.String target)
public int copyFrom(java.lang.String sourcePath, java.io.File localPath, boolean recursive) throws SshException
ExecInterface
copyFrom
in interface ExecInterface
copyFrom
in class RemoteExec
SshException
protected int _copyTo(java.io.File lfile, java.lang.String targetPath, boolean recursive) throws SshException
_copyTo
in class RemoteExec
SshException
public int executeCmd(java.lang.String command, java.io.OutputStream streamOut, java.io.OutputStream streamErr) throws ExecException
ExecInterface
ExecException
public int executeCmd(java.lang.String command, java.io.OutputStream streamOut, java.io.OutputStream streamErr, java.lang.String thirdPartyTarget) throws ExecException
ExecInterface
ExecException
public java.util.List getAvailableAuthMethods() throws SshException
SshException
public boolean openConnection() throws SshException
openConnection
in interface ExecInterface
openConnection
in class RemoteExec
SshException
public boolean openConnection(boolean authenticate) throws SshException
SshException
public boolean authenticate(boolean externalkeyx) throws SshException
SshException
public void closeConnection()
closeConnection
in interface ExecInterface
closeConnection
in class RemoteExec
public void setForcedCleanUp(boolean forcedCleanUp)
ExecInterface
public void setTimeout(int seconds, boolean stdout, boolean stderr)
ExecInterface
public void addIdentity(java.lang.String identity)
public void setPortForwardingL(java.lang.String spec) throws ExecException
ExecException
public void setPortForwardingR(java.lang.String spec) throws ExecException
ExecException
public boolean getForcedCleanUp()
getForcedCleanUp
in class RemoteExec
public int getTimeout()
getTimeout
in class RemoteExec
public void setTimeout(int seconds)
ExecInterface