Skip to main content

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

PtyType
required
The type of pseudo-terminal to use for the shell session.PtyType Enum Values:
  • VANILLA: Basic terminal without special control sequences
  • VT100: DEC VT100 terminal emulation
  • VT102: DEC VT102 terminal emulation
  • VT220: DEC VT220 terminal emulation
  • ANSI: ANSI standard terminal
  • XTERM: XTerm terminal emulation (most common)
CallbackFunction<string>
Optional callback function to handle the response.Type Definition:

Return Value

Promise<string>
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

string
required
The command to write to the shell.
CallbackFunction<string>
Optional callback function to handle the response.Type Definition:

Return Value

Promise<string>
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.VANILLA if 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

void
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

any
The shell output data received from the server.

Usage Example

Removing a handler

Use off() (or its alias removeListener()) to remove a previously registered handler, for example when tearing down a component:
string
required
The name of the event whose handler should be removed (for example, 'Shell').

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

'vanilla'
Basic terminal type without special control sequences. Use for simple command execution.
'vt100'
DEC VT100 terminal emulation. Classic terminal type with basic cursor control.
'vt102'
DEC VT102 terminal emulation. Enhanced version of VT100 with additional features.
'vt220'
DEC VT220 terminal emulation. Advanced terminal type with extended capabilities.
'ansi'
ANSI standard terminal. Supports ANSI escape sequences for colors and formatting.
'xterm'
XTerm terminal emulation. Most widely supported modern terminal type. Recommended for most use cases.

Usage Example

Last modified on July 4, 2026