Overview
TheSSHClient 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 authenticationSSHClient.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
TheSSHClient class provides the following static methods:
Connection Factory Methods
connectWithPassword()- Create an SSH connection using password authenticationconnectWithKey()- Create an SSH connection using private key authentication
Key Management Methods
generateKeyPair()- Generate a new SSH key pairgetKeyDetails()- Retrieve details about an SSH private key
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.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
Other Instance Methods
For documentation on other instance methods, see:- SSH Operations - Execute commands and manage interactive shells
- SFTP Operations - File transfer and remote file system operations
- Connection Management - Disconnect and manage connections