node-ssh

  • Version 13.2.0
  • Published
  • 78.2 kB
  • 6 dependencies
  • MIT license

Install

npm i node-ssh
yarn add node-ssh
pnpm add node-ssh

Overview

SSH2 with Promises

Index

Classes

class NodeSSH

class NodeSSH {}

    property connection

    connection: any;

      method connect

      connect: (givenConfig: Config) => Promise<this>;

        method dispose

        dispose: () => void;

          method exec

          exec: {
          (
          command: string,
          parameters: string[],
          options?: SSHExecOptions & { stream?: 'stdout' | 'stderr' }
          ): Promise<string>;
          (
          command: string,
          parameters: string[],
          options?: SSHExecOptions & { stream: 'both' }
          ): Promise<SSHExecCommandResponse>;
          };

            method execCommand

            execCommand: (
            givenCommand: string,
            options?: SSHExecCommandOptions
            ) => Promise<SSHExecCommandResponse>;

              method forwardIn

              forwardIn: (
              remoteAddr: string,
              remotePort: number,
              onConnection?: SSHForwardInListener
              ) => Promise<SSHForwardInDetails>;

                method forwardInStreamLocal

                forwardInStreamLocal: (
                socketPath: string,
                onConnection?: SSHForwardInStreamLocalListener
                ) => Promise<SSHForwardInStreamLocalDetails>;

                  method forwardOut

                  forwardOut: (
                  srcIP: string,
                  srcPort: number,
                  dstIP: string,
                  dstPort: number
                  ) => Promise<Channel>;

                    method forwardOutStreamLocal

                    forwardOutStreamLocal: (socketPath: string) => Promise<Channel>;

                      method getDirectory

                      getDirectory: (
                      localDirectory: string,
                      remoteDirectory: string,
                      {
                      concurrency,
                      sftp: givenSftp,
                      transferOptions,
                      recursive,
                      tick,
                      validate,
                      }?: SSHGetPutDirectoryOptions
                      ) => Promise<boolean>;

                        method getFile

                        getFile: (
                        localFile: string,
                        remoteFile: string,
                        givenSftp?: SFTPWrapper | null,
                        transferOptions?: TransferOptions | null
                        ) => Promise<void>;

                          method isConnected

                          isConnected: () => boolean;

                            method mkdir

                            mkdir: (
                            path: string,
                            method?: SSHMkdirMethod,
                            givenSftp?: SFTPWrapper | null
                            ) => Promise<void>;

                              method putDirectory

                              putDirectory: (
                              localDirectory: string,
                              remoteDirectory: string,
                              {
                              concurrency,
                              sftp: givenSftp,
                              transferOptions,
                              recursive,
                              tick,
                              validate,
                              }?: SSHGetPutDirectoryOptions
                              ) => Promise<boolean>;

                                method putFile

                                putFile: (
                                localFile: string,
                                remoteFile: string,
                                givenSftp?: SFTPWrapper | null,
                                transferOptions?: TransferOptions | null
                                ) => Promise<void>;

                                  method putFiles

                                  putFiles: (
                                  files: { local: string; remote: string }[],
                                  { concurrency, sftp: givenSftp, transferOptions }?: SSHPutFilesOptions
                                  ) => Promise<void>;

                                    method requestSFTP

                                    requestSFTP: () => Promise<SFTPWrapper>;

                                      method requestShell

                                      requestShell: (
                                      options?: PseudoTtyOptions | ShellOptions | false
                                      ) => Promise<ClientChannel>;

                                        method withSFTP

                                        withSFTP: (callback: (sftp: SFTPWrapper) => Promise<void>) => Promise<void>;

                                          method withShell

                                          withShell: (
                                          callback: (channel: ClientChannel) => Promise<void>,
                                          options?: PseudoTtyOptions | ShellOptions | false
                                          ) => Promise<void>;

                                            class SSHError

                                            class SSHError extends Error {}

                                              constructor

                                              constructor(message: string, code?: string);

                                                property code

                                                code: string;

                                                  Interfaces

                                                  interface SSHExecCommandOptions

                                                  interface SSHExecCommandOptions {}

                                                    property cwd

                                                    cwd?: string;

                                                      property encoding

                                                      encoding?: BufferEncoding;

                                                        property execOptions

                                                        execOptions?: ExecOptions;

                                                          property noTrim

                                                          noTrim?: boolean;

                                                            property onChannel

                                                            onChannel?: (clientChannel: ClientChannel) => void;

                                                              property onStderr

                                                              onStderr?: (chunk: Buffer) => void;

                                                                property onStdout

                                                                onStdout?: (chunk: Buffer) => void;

                                                                  property stdin

                                                                  stdin?: string | stream.Readable;

                                                                    interface SSHExecCommandResponse

                                                                    interface SSHExecCommandResponse {}

                                                                      property code

                                                                      code: number | null;

                                                                        property signal

                                                                        signal: string | null;

                                                                          property stderr

                                                                          stderr: string;

                                                                            property stdout

                                                                            stdout: string;

                                                                              interface SSHExecOptions

                                                                              interface SSHExecOptions extends SSHExecCommandOptions {}

                                                                                property stream

                                                                                stream?: 'stdout' | 'stderr' | 'both';

                                                                                  interface SSHForwardInDetails

                                                                                  interface SSHForwardInDetails {}

                                                                                    property port

                                                                                    port: number;

                                                                                      method dispose

                                                                                      dispose: () => Promise<void>;

                                                                                        interface SSHForwardInStreamLocalDetails

                                                                                        interface SSHForwardInStreamLocalDetails {}

                                                                                          method dispose

                                                                                          dispose: () => Promise<void>;

                                                                                            interface SSHGetPutDirectoryOptions

                                                                                            interface SSHGetPutDirectoryOptions extends SSHPutFilesOptions {}

                                                                                              property recursive

                                                                                              recursive?: boolean;

                                                                                                property tick

                                                                                                tick?: (localFile: string, remoteFile: string, error: Error | null) => void;

                                                                                                  property validate

                                                                                                  validate?: (path: string) => boolean;

                                                                                                    interface SSHPutFilesOptions

                                                                                                    interface SSHPutFilesOptions {}

                                                                                                      property concurrency

                                                                                                      concurrency?: number;

                                                                                                        property sftp

                                                                                                        sftp?: SFTPWrapper | null;

                                                                                                          property transferOptions

                                                                                                          transferOptions?: TransferOptions;

                                                                                                            Type Aliases

                                                                                                            type Config

                                                                                                            type Config = ConnectConfig & {
                                                                                                            password?: string;
                                                                                                            privateKey?: string;
                                                                                                            privateKeyPath?: string;
                                                                                                            tryKeyboard?: boolean;
                                                                                                            onKeyboardInteractive?: (
                                                                                                            name: string,
                                                                                                            instructions: string,
                                                                                                            lang: string,
                                                                                                            prompts: Prompt[],
                                                                                                            finish: (responses: string[]) => void
                                                                                                            ) => void;
                                                                                                            };

                                                                                                              type SSHForwardInListener

                                                                                                              type SSHForwardInListener = (
                                                                                                              details: TcpConnectionDetails,
                                                                                                              accept: AcceptConnection<ClientChannel>,
                                                                                                              reject: RejectConnection
                                                                                                              ) => void;

                                                                                                                type SSHForwardInStreamLocalListener

                                                                                                                type SSHForwardInStreamLocalListener = (
                                                                                                                info: UNIXConnectionDetails,
                                                                                                                accept: AcceptConnection,
                                                                                                                reject: RejectConnection
                                                                                                                ) => void;

                                                                                                                  type SSHMkdirMethod

                                                                                                                  type SSHMkdirMethod = 'sftp' | 'exec';

                                                                                                                    Package Files (1)

                                                                                                                    Dependencies (6)

                                                                                                                    Dev Dependencies (11)

                                                                                                                    Peer Dependencies (0)

                                                                                                                    No peer dependencies.

                                                                                                                    Badge

                                                                                                                    To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                                                                                    You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/node-ssh.

                                                                                                                    • Markdown
                                                                                                                      [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/node-ssh)
                                                                                                                    • HTML
                                                                                                                      <a href="https://www.jsdocs.io/package/node-ssh"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>