tuzig / capacitor-ssh-plugin

An ssh plugin for hybrid apps, supports both iOS and Android.
MIT License
1 stars 2 forks source link

capacitor-ssh-plugin

Supporting libssh2 sessions and channels. Supports both iOS and Android.

Install

npm install capacitor-ssh-plugin
npx cap sync

API

* [`startSessionByPasswd(...)`](#startsessionbypasswd) * [`startSessionByKey(...)`](#startsessionbykey) * [`newChannel(...)`](#newchannel) * [`startShell(...)`](#startshell) * [`writeToChannel(...)`](#writetochannel) * [`closeChannel(...)`](#closechannel) * [`setPtySize(...)`](#setptysize) * [Interfaces](#interfaces) * [Type Aliases](#type-aliases) * [Enums](#enums) ### startSessionByPasswd(...) ```typescript startSessionByPasswd(options: StartByPasswd) => Promise ``` connect to a host using a username & password | Param | Type | | ------------- | ------------------------------------------------------- | | **`options`** | StartByPasswd | **Returns:** Promise<string> -------------------- ### startSessionByKey(...) ```typescript startSessionByKey(options: StartByKey) => Promise<{ session: string; }> ``` connect to a host using an identity key. The pa | Param | Type | | ------------- | ------------------------------------------------- | | **`options`** | StartByKey | **Returns:** Promise<{ session: string; }> -------------------- ### newChannel(...) ```typescript newChannel(options: { session: SSHSessionID; pty?: TerminalType; }) => Promise<{ id: number; }> ``` given a connected session and an optional terminal type, start a new channel | Param | Type | | ------------- | --------------------------------------------------------------------------------- | | **`options`** | { session: string; pty?: TerminalType; } | **Returns:** Promise<{ id: number; }> -------------------- ### startShell(...) ```typescript startShell(options: { channel: SSHChannelID; command?: string; }, callback: STDOutCallback) => Promise ``` given a channel, start a login shell. The function also recieves a callback which is called when messages arrive on the channel. | Param | Type | | -------------- | --------------------------------------------------------- | | **`options`** | { channel: number; command?: string; } | | **`callback`** | STDOutCallback | **Returns:** Promise<string> -------------------- ### writeToChannel(...) ```typescript writeToChannel(options: { channel: number; s: string; }) => Promise ``` writes a message to an open channel | Param | Type | | ------------- | -------------------------------------------- | | **`options`** | { channel: number; s: string; } | -------------------- ### closeChannel(...) ```typescript closeChannel(options: { channel: number; }) => Promise ``` | Param | Type | | ------------- | --------------------------------- | | **`options`** | { channel: number; } | -------------------- ### setPtySize(...) ```typescript setPtySize(options: { channel: number; width: number; height: number; }) => Promise ``` | Param | Type | | ------------- | ---------------------------------------------------------------- | | **`options`** | { channel: number; width: number; height: number; } | -------------------- ### Interfaces #### StartByPasswd parameters used when opening a session by password | Prop | Type | | -------------- | ------------------- | | **`address`** | string | | **`port`** | number | | **`username`** | string | | **`password`** | string | #### StartByKey parameters used when opening a session by indetity key | Prop | Type | | -------------- | ------------------- | | **`address`** | string | | **`port`** | number | | **`username`** | string | | **`tag`** | string | ### Type Aliases #### SSHSessionID Session ID string #### SSHChannelID Channel ID number #### STDOutCallback (message: string | null, err?: any): void ### Enums #### TerminalType | Members | Value | | ------------------------ | -------------- | | **`PtyNone`** | 0 | | **`PtyTerminalVanilla`** | | | **`PtyTerminalVT100`** | | | **`PtyTerminalVT102`** | | | **`PtyTerminalVT220`** | | | **`PtyTerminalAnsi`** | | | **`PtyTerminalXterm`** | |