Overview
Manage interactive shell sessions on the SSH server, allowing you to start shells, write commands, and handle shell output through events.startShell()
Starts an interactive shell session on the SSH server.Method Signature
Parameters
The type of pseudo-terminal to use for the shell session.PtyType Enum Values:
VANILLA: Basic terminal without special control sequencesVT100: DEC VT100 terminal emulationVT102: DEC VT102 terminal emulationVT220: DEC VT220 terminal emulationANSI: ANSI standard terminalXTERM: XTerm terminal emulation (most common)
Optional callback function to handle the response.Type Definition:
Return Value
Returns a Promise that resolves with the initial shell response.
- Resolves: With the initial output from the shell session
- Rejects: With an error if the shell session fails to start
- Note: If a shell is already active, returns an empty string
Usage Example
writeToShell()
Writes a command to the active shell session.Method Signature
Parameters
The command to write to the shell.
Optional callback function to handle the response.Type Definition:
Return Value
Returns a Promise that resolves with the response from the shell.
- Resolves: With the shell output after executing the command
- Rejects: With an error if the write operation fails
Usage Example
Notes
- Automatically starts a shell session with
PtyType.VANILLAif one is not already active - Commands are executed in the context of the active shell session
- State is maintained between calls (e.g., directory changes persist)
closeShell()
Closes the active SSH shell session.Method Signature
Parameters
None.Return Value
This method does not return a value.
Usage Example
Notes
- Unregisters the ‘Shell’ event listener
- Sets the internal shell active state to false
- Should be called when you no longer need the shell session
Shell Event
The ‘Shell’ event is emitted during shell operations to provide real-time output.Event Handler
Register a handler to receive shell output:Event Handler Type
Parameters
The shell output data received from the server.
Usage Example
Notes
- The ‘Shell’ event listener is automatically registered when calling
startShell() - The event provides real-time output from the shell session
- The listener is automatically unregistered when calling
closeShell()
PtyType Enum
Defines the types of pseudo-terminals (PTY) available for SSH shell connections.Enum Definition
Values
Basic terminal type without special control sequences. Use for simple command execution.
DEC VT100 terminal emulation. Classic terminal type with basic cursor control.
DEC VT102 terminal emulation. Enhanced version of VT100 with additional features.
DEC VT220 terminal emulation. Advanced terminal type with extended capabilities.
ANSI standard terminal. Supports ANSI escape sequences for colors and formatting.
XTerm terminal emulation. Most widely supported modern terminal type. Recommended for most use cases.