Skip to main content

Overview

The SSHClient class is the main interface for SSH and SFTP operations in the React Native SSH SFTP library. Instances are created using static factory methods rather than the constructor directly. Instances should be created using:
  • SSHClient.connectWithPassword() - For password authentication
  • SSHClient.connectWithKey() - For private key authentication

Constructor

The constructor is private and should not be called directly. Use the static factory methods instead.
Do not instantiate SSHClient directly. Use connectWithPassword() or connectWithKey() static methods.

Static Methods Overview

The SSHClient class provides the following static methods:

Connection Factory Methods

  • connectWithPassword() - Create an SSH connection using password authentication
  • connectWithKey() - Create an SSH connection using private key authentication
For detailed documentation, see Connection Methods.

Key Management Methods

  • generateKeyPair() - Generate a new SSH key pair
  • getKeyDetails() - Retrieve details about an SSH private key
For detailed documentation, see Connection Methods.

Types

PtyType

Represents the types of PTY (pseudo-terminal) for SSH shell connections.

CallbackFunction

Represents a callback function with an optional response.

EventHandler

Represents an event handler function.

LsResult

Represents the result of a directory listing operation.

KeyPair

Represents a key pair used for SSH authentication.

PasswordOrKey

Represents a password or key for authentication.

Instance Methods

Event Handling

on()

Registers an event handler for the specified event. This method is used to listen to asynchronous events from shell sessions and file transfers.
Parameters:
  • eventName (string) - The name of the event to listen for. Supported events:
    • 'Shell' - Receives output from interactive shell sessions
    • 'UploadProgress' - Receives progress updates during file uploads
    • 'DownloadProgress' - Receives progress updates during file downloads
  • handler (EventHandler) - The function to call when the event occurs
Usage Example:

Other Instance Methods

For documentation on other instance methods, see:
Last modified on March 26, 2026