public class SshProvider
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private com.jcraft.jsch.Channel |
channel
The channel.
|
private static org.slf4j.Logger |
logger
The logger.
|
private com.jcraft.jsch.Session |
session
The session.
|
private SshMeta |
sshMeta
The ssh meta.
|
private java.lang.String |
targetHost
The target host.
|
Constructor and Description |
---|
SshProvider()
Instantiates a new ssh provider.
|
SshProvider(SshMeta sshMeta,
java.lang.String targetHost)
Instantiates a new ssh provider.
|
Modifier and Type | Method and Description |
---|---|
ResponseOnSingeRequest |
executeAndGenResponse(com.jcraft.jsch.ChannelExec channel)
Seems there are bad naming in the library the sysout is in
channel.getInputStream(); the syserr is in
((ChannelExec)channel).setErrStream(os);
|
ResponseOnSingeRequest |
executeSshCommand()
finally: will close the connection.
|
ResponseOnSingeRequest |
genErrorResponse(java.lang.Exception t)
Gen error response.
|
SshMeta |
getSshMeta()
Gets the ssh meta.
|
java.lang.String |
getTargetHost()
Gets the target host.
|
com.jcraft.jsch.Channel |
sessionConnectGenerateChannel(com.jcraft.jsch.Session session)
Session connect generate channel.
|
void |
setSshMeta(SshMeta sshMeta)
Sets the ssh meta.
|
void |
setTargetHost(java.lang.String targetHost)
Sets the target host.
|
com.jcraft.jsch.Session |
startSshSessionAndObtainSession()
Start ssh session and obtain session.
|
private static org.slf4j.Logger logger
private SshMeta sshMeta
private java.lang.String targetHost
private com.jcraft.jsch.Session session
private com.jcraft.jsch.Channel channel
public SshProvider(SshMeta sshMeta, java.lang.String targetHost)
sshMeta
- the ssh metatargetHost
- the target hostpublic SshProvider()
public ResponseOnSingeRequest executeSshCommand()
public com.jcraft.jsch.Session startSshSessionAndObtainSession()
public com.jcraft.jsch.Channel sessionConnectGenerateChannel(com.jcraft.jsch.Session session) throws com.jcraft.jsch.JSchException
session
- the sessioncom.jcraft.jsch.JSchException
- the j sch exceptionpublic ResponseOnSingeRequest executeAndGenResponse(com.jcraft.jsch.ChannelExec channel)
channel
- the channelpublic ResponseOnSingeRequest genErrorResponse(java.lang.Exception t)
t
- the tpublic SshMeta getSshMeta()
public void setSshMeta(SshMeta sshMeta)
sshMeta
- the new ssh metapublic java.lang.String getTargetHost()
public void setTargetHost(java.lang.String targetHost)
targetHost
- the new target host