public class Ssh2Session extends Ssh2Channel implements SshSession
SESSION_CHANNELCHANNEL_CLOSED, CHANNEL_OPEN, CHANNEL_UNINITIALIZED, channelid, manager, ms, stateEXITCODE_NOT_RECEIVED| Constructor and Description | 
|---|
| Ssh2Session(int windowsize,
           int packetsize,
           Ssh2Client client)Construct a session channel. | 
| Modifier and Type | Method and Description | 
|---|---|
| void | changeTerminalDimensions(int cols,
                        int rows,
                        int width,
                        int height)Change the dimensions of the terminal window. | 
| protected void | channelRequest(String requesttype,
              boolean wantreply,
              byte[] requestdata)This overidden method handles the "exit-status", "exit-signal" and
 "xon-xoff" channel requests. | 
| protected void | checkCloseStatus(boolean remoteClosed) | 
| boolean | executeCommand(String cmd)Execute a command. | 
| boolean | executeCommand(String cmd,
              String charset)Execute a command. | 
| int | exitCode()Return the exit code of the process once complete. | 
| SshClient | getClient()The SshClient that this channel belongs to | 
| String | getExitSignalInfo()Get the exit signal information, may be an empty string. | 
| InputStream | getStderrInputStream()Get an InputStream to read the process stderr. | 
| String | getTerm()Returns the term type of any pseudo terminal successfully attached to session. | 
| boolean | hasExitSignal()Determine whether the remote process was signalled. | 
| boolean | isFlowControlEnabled()On many systems it is possible to determine whether a pseudo-terminal is
 using control-S/ control-Q flow control. | 
| protected void | processExtendedData(int typecode,
                   int length,
                   SshChannelMessage msg)Called when extended data arrives. | 
| boolean | requestPseudoTerminal(String term,
                     int cols,
                     int rows,
                     int width,
                     int height)The remote process may require a pseudo terminal. | 
| boolean | requestPseudoTerminal(String term,
                     int cols,
                     int rows,
                     int width,
                     int height,
                     byte[] modes)The remote process may require a pseudo terminal. | 
| boolean | requestPseudoTerminal(String term,
                     int cols,
                     int rows,
                     int width,
                     int height,
                     PseudoTerminalModes terminalModes)The remote process may require a pseudo terminal. | 
| boolean | setEnvironmentVariable(String name,
                      String value)The SSH2 session supports the setting of environments variables however
 in our experience no server to date allows unconditional setting of
 variables. | 
| void | signal(String signal)Send a signal to the remote process. | 
| boolean | startShell()Start the users default shell. | 
| boolean | startSubsystem(String subsystem)SSH2 supports special subsystems that are identified by a name rather
 than a command string, an example of an SSH2 subsystem is SFTP. | 
addChannelEventListener, channelEOF, close, create, createExtendedDataStream, equals, free, getConnection, getInputStream, getMaximumLocalPacketLength, getMaximumLocalWindowSize, getMaximumRemotePacketLength, getMaximumRemoteWindowSize, getMessageStore, getName, getOutputStream, getRemoteWindow, getStickyMessageIds, idle, isSendKeepAliveOnIdle, open, open, processChannelMessage, processStandardData, removeChannelEventListener, sendRequest, sendRequest, setAutoConsumeInput, setSendKeepAliveOnIdlegetChannelId, getMessageRouter, init, isClosed, waitForOpenclone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitclose, getInputStream, getOutputStream, isClosedaddChannelEventListener, getChannelId, getMaximumLocalPacketLength, getMaximumLocalWindowSize, getMaximumRemotePacketLength, getMaximumRemoteWindowSize, getMessageRouter, getRemoteWindow, removeChannelEventListener, setAutoConsumeInput, waitForOpenpublic Ssh2Session(int windowsize,
                   int packetsize,
                   Ssh2Client client)
windowsize - the initial/maximum window space availablepacketsize - the maximum packet sizepublic SshClient getClient()
SshChannelgetClient in interface SshChannelgetClient in interface SshSessiongetClient in class Ssh2Channelpublic String getTerm()
SshSessiongetTerm in interface SshSessionprotected void processExtendedData(int typecode,
                                   int length,
                                   SshChannelMessage msg)
                            throws SshException
Ssh2Channelcom.maverick.ssh.ChannelEventListener#extendedDataReceived(com.maverick.ssh.Channel, byte[], int, int, int)
 event so to maintain code compatibility always call the super
 method in any overidden method.processExtendedData in class Ssh2Channeltypecode - the type of extended dataSshExceptionpublic InputStream getStderrInputStream()
SshSessiongetStderrInputStream in interface SshSessionpublic boolean requestPseudoTerminal(String term, int cols, int rows, int width, int height) throws SshException
SshSessionrequestPseudoTerminal in interface SshSessionterm - the terminal type e.g "vt100"cols - the number of columnsrows - the number of rowswidth - the width of the terminal (informational only, can be zero)height - the height of the terminal (informational only, can be zero)true if the pty was allocated, otherwise falseSshExceptionpublic boolean requestPseudoTerminal(String term, int cols, int rows, int width, int height, PseudoTerminalModes terminalModes) throws SshException
SshSessionrequestPseudoTerminal in interface SshSessionterm - the terminal type e.g "vt100"cols - the number of columnsrows - the number of rowswidth - the width of the terminal (informational only, can be zero)height - the height of the terminal (informational only, can be zero)terminalModes - the known terminal modestrue if the pty was allocated, otherwise falseSshExceptionpublic boolean requestPseudoTerminal(String term, int cols, int rows, int width, int height, byte[] modes) throws SshException
SshSessionrequestPseudoTerminal in interface SshSessionterm - the terminal type e.g "vt100"cols - the number of columnsrows - the number of rowswidth - the width of the terminal (informational only, can be zero)height - the height of the terminal (informational only, can be zero)modes - an array of encoded terminal modes as described in the
              SSH protocol specifications.true if the pty was allocated, otherwise falseSshExceptionpublic boolean startShell()
                   throws SshException
SshSessionstartShell in interface SshSessiontrue if the shell was started, otherwise
         falseSshExceptionpublic boolean executeCommand(String cmd) throws SshException
SshSessionexecuteCommand in interface SshSessiontrue if the command was accepted, otherwise
         false. This may not return false if the
         command is incorrect, it should only be used as an
         indication that the command was accepted and that the
         server will attempt to execute it.SshExceptionpublic boolean executeCommand(String cmd, String charset) throws SshException
SshSessionexecuteCommand in interface SshSessiontrue if the command was accepted, otherwise
         false. This may not return false if the
         command is incorrect, it should only be used as an
         indication that the command was accepted and that the
         server will attempt to execute it.SshExceptionpublic boolean startSubsystem(String subsystem) throws SshException
subsystem - the name of the subsystem, for example "sftp"true if the subsystem was started, otherwise
         falseSshExceptionpublic boolean setEnvironmentVariable(String name, String value) throws SshException
SshExceptionpublic void changeTerminalDimensions(int cols,
                                     int rows,
                                     int width,
                                     int height)
                              throws SshException
SshSessionchangeTerminalDimensions in interface SshSessionSshExceptionpublic boolean isFlowControlEnabled()
true the
 client is allowed to do flow control using control-S and control-Qpublic void signal(String signal) throws SshException
ABRT ALRM FPE HUP ILL INT KILL PIPE QUIT SEGV TERM USR1 USR2
signal - IOExceptionSshExceptionprotected void channelRequest(String requesttype, boolean wantreply, byte[] requestdata) throws SshException
channelRequest in class Ssh2Channelrequesttype - the name of the requestwantreply - specifies whether the remote side requires a success/failure
            messagerequestdata - the request dataSshExceptionpublic int exitCode()
SshSessionexitCode in interface SshSessionprotected void checkCloseStatus(boolean remoteClosed)
checkCloseStatus in class Ssh2Channelpublic boolean hasExitSignal()
true if a signal was received, otherwise
         falsepublic String getExitSignalInfo()
Copyright © 2025. All rights reserved.