{"name":"node-ssh","version":"9.0.0","keywords":["ssh","ssh2","sftp"],"author":{"name":"steelbrain"},"license":"MIT","_id":"node-ssh@9.0.0","maintainers":[{"name":"steelbrain","email":"i@steelbrain.me"}],"homepage":"https://github.com/steelbrain/node-ssh#readme","bugs":{"url":"https://github.com/steelbrain/node-ssh/issues"},"ava":{"files":["test/*-test.ts"],"require":["ts-node/register/transpile-only"],"extensions":["ts"]},"dist":{"shasum":"50ed464ea16d9d2c11389d0485f2a5e640f3494c","tarball":"http://registry-npm.ywwl.com/node-ssh/download/node-ssh-9.0.0.tgz","fileCount":6,"integrity":"sha512-nWHQ5m8x8YAI2eKfxNM5j16Qc++xWRc3OXkAtfKkY/vwu7/nN28X+aU6B+ajBcOci+LtHBprSmVebmb9G87FEw==","signatures":[{"sig":"MEUCIQCP5xWpAJVX9WMy63Fj9g994KSoZNk4Kjs8wNkh+49+KgIgUoty4dlMgNHv9eIK8kGLlNv8jFpxtXZtEqLjFCSw9BU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":41935,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJer/0HCRA9TVsSAnZWagAAaRoP+wVbzU7sWXBz8MtH5O/x\nVoRx7T/3yJGcGILlrenyG6sM4axug9bnt1hfyBmIrChHTu7NK+pVIKHnXWRe\nQTCS71YUFlbfsMW5YS2+MimMQCnetbDSG71Nj5eIJjkUH5uz7tN068rCeGpd\n28Rm2p4Lij/XPrwF2Sdw1FmLBgzP7OWyWhkbTABnD6Je7B9m7pPq14LgikXK\nt/uq0KTX3SxENCNRnBN0p4V5R9giCUbc/0m2V+LKbQmdfBK0QMIrvzSTdfUU\nty8teFjRrA55rgaM4/MVk50MycqUuxqCGG7araJNwfh+a6EiJJB5q4aEilcz\ncpL8QLUXbSCiS4pcofEDX4pUTdqBIWTfq4zgxoc1lNjGNgkSnXcJAKscopdf\n29ZTgQPj57ZIH/hxW8ZpeEWHs8vaS9ibU0u1T+v8u6MkxscmqGOO84dxpLDf\n9DVqo7G/znmEwr6wBjxUMnKxxqQW0jqX4dp/v97pgXykvy+cQRVVVlhpWuDU\naYwNt+YquX+CM5MosoEcXaleymQ8ih2n0T+sHnKYeLH6VKCh2lnNeC676GgF\nk3rGvDbyFROPl7r/CY714bSzsZ5Qe3bdnNev6CE4f7AeDFOFuwunBqwFA+f3\ncybkVWX6TcYeusSmuMVOFH/hMC/wyesyEDjTeeeiVDM5K1Thoc3SxUdwFYzD\noXu9\r\n=U39D\r\n-----END PGP SIGNATURE-----\r\n","size":9356,"noattachment":false,"key":"/node-ssh/-/node-ssh-9.0.0.tgz"},"main":"lib/cjs/index.js","module":"lib/esm/index.js","engines":{"node":">= 8"},"gitHead":"7a46e931a74a7ba18dfee540e3a91c9ddbb9b1c7","scripts":{"lint":"(tsc -p . --noEmit) && (eslint . --ext .ts) && (prettier --list-different src/*.ts)","test":"ava","prepare":"yarn build:clean ; yarn build:cjs ; yarn build:typings","build:cjs":"tsc --module commonjs --target es2018 --outDir lib/cjs","build:clean":"rm -rf lib","build:typings":"tsc --declaration --outDir lib/typings --emitDeclarationOnly"},"typings":"lib/typings/index.d.ts","_npmUser":{"name":"steelbrain","email":"i@steelbrain.me"},"repository":{"url":"git+https://github.com/steelbrain/node-ssh.git","type":"git"},"_npmVersion":"6.14.4","description":"SS2 with Promises","directories":{},"_nodeVersion":"12.16.2","dependencies":{"ssh2":"^0.8.9","make-dir":"^3.1.0","sb-scandir":"^3.0.0","shell-escape":"^0.2.0","sb-promise-queue":"^2.0.0"},"_hasShrinkwrap":false,"devDependencies":{"ava":"^3.7.0","ts-node":"^8.8.2","node-pty":"^0.9.0","typescript":"^3.8.3","@types/ssh2":"^0.5.43","ssh2-streams":"^0.4.10","@types/shell-escape":"^0.2.0","eslint-config-steelbrain":"^9.0.1"},"_npmOperationalInternal":{"tmp":"tmp/node-ssh_9.0.0_1588591879276_0.5769338835535276","host":"s3://npm-registry-packages"},"readme":"Node-SSH - SSH2 with Promises\n=========\n\nNode-SSH is an extremely lightweight Promise wrapper for [ssh2][ssh2].\n\n#### Installation\n\n```sh\n$ npm install node-ssh # If you're using npm\n$ yarn add node-ssh # If you're using Yarn\n```\n\n#### Example\n\n```js\nconst fs = require('fs')\nconst path = require('path')\nconst {NodeSSH} = require('node-ssh')\n\nconst ssh = new NodeSSH()\n\nssh.connect({\n  host: 'localhost',\n  username: 'steel',\n  privateKeyPath: '/home/steel/.ssh/id_rsa'\n})\n\n// or with inline privateKey\n\nssh.connect({\n  host: 'localhost',\n  username: 'steel',\n  privateKey: Buffer.from('...')\n})\n.then(function() {\n  // Local, Remote\n  ssh.putFile('/home/steel/Lab/localPath/fileName', '/home/steel/Lab/remotePath/fileName').then(function() {\n    console.log(\"The File thing is done\")\n  }, function(error) {\n    console.log(\"Something's wrong\")\n    console.log(error)\n  })\n  // Array<Shape('local' => string, 'remote' => string)>\n  ssh.putFiles([{ local: '/home/steel/Lab/localPath/fileName', remote: '/home/steel/Lab/remotePath/fileName' }]).then(function() {\n    console.log(\"The File thing is done\")\n  }, function(error) {\n    console.log(\"Something's wrong\")\n    console.log(error)\n  })\n  // Local, Remote\n  ssh.getFile('/home/steel/Lab/localPath', '/home/steel/Lab/remotePath').then(function(Contents) {\n    console.log(\"The File's contents were successfully downloaded\")\n  }, function(error) {\n    console.log(\"Something's wrong\")\n    console.log(error)\n  })\n  // Putting entire directories\n  const failed = []\n  const successful = []\n  ssh.putDirectory('/home/steel/Lab', '/home/steel/Lab', {\n    recursive: true,\n    concurrency: 10,\n    // ^ WARNING: Not all servers support high concurrency\n    // try a bunch of values and see what works on your server\n    validate: function(itemPath) {\n      const baseName = path.basename(itemPath)\n      return baseName.substr(0, 1) !== '.' && // do not allow dot files\n             baseName !== 'node_modules' // do not allow node_modules\n    },\n    tick: function(localPath, remotePath, error) {\n      if (error) {\n        failed.push(localPath)\n      } else {\n        successful.push(localPath)\n      }\n    }\n  }).then(function(status) {\n    console.log('the directory transfer was', status ? 'successful' : 'unsuccessful')\n    console.log('failed transfers', failed.join(', '))\n    console.log('successful transfers', successful.join(', '))\n  })\n  // Command\n  ssh.execCommand('hh_client --json', { cwd:'/var/www' }).then(function(result) {\n    console.log('STDOUT: ' + result.stdout)\n    console.log('STDERR: ' + result.stderr)\n  })\n  // Command with escaped params\n  ssh.exec('hh_client', ['--json'], { cwd: '/var/www', stream: 'stdout', options: { pty: true } }).then(function(result) {\n    console.log('STDOUT: ' + result)\n  })\n  // With streaming stdout/stderr callbacks\n  ssh.exec('hh_client', ['--json'], {\n    cwd: '/var/www',\n    onStdout(chunk) {\n      console.log('stdoutChunk', chunk.toString('utf8'))\n    },\n    onStderr(chunk) {\n      console.log('stderrChunk', chunk.toString('utf8'))\n    },\n  })\n})\n```\n\n#### API\n\n```ts\n// API reference in Typescript typing format:\nimport SSH2, {\n  AcceptConnection,\n  Channel,\n  ClientChannel,\n  ConnectConfig,\n  ExecOptions,\n  Prompt,\n  PseudoTtyOptions,\n  RejectConnection,\n  SFTPWrapper,\n  ShellOptions,\n  TcpConnectionDetails,\n  TransferOptions,\n  UNIXConnectionDetails,\n} from 'ssh2'\nimport stream from 'stream'\n\n// ^ You do NOT need to import these package, these are here for reference of where the\n// types are coming from.\n\nexport type Config = ConnectConfig & {\n  password?: string\n  privateKey?: string\n  privateKeyPath?: string\n  tryKeyboard?: boolean\n  onKeyboardInteractive?: (\n    name: string,\n    instructions: string,\n    lang: string,\n    prompts: Prompt[],\n    finish: (responses: string[]) => void,\n  ) => void\n}\nexport interface SSHExecCommandOptions {\n  cwd?: string\n  stdin?: string | stream.Readable\n  execOptions?: ExecOptions\n  encoding?: BufferEncoding\n  noTrim?: boolean\n  onChannel?: (clientChannel: ClientChannel) => void\n  onStdout?: (chunk: Buffer) => void\n  onStderr?: (chunk: Buffer) => void\n}\nexport interface SSHExecCommandResponse {\n  stdout: string\n  stderr: string\n  code: number | null\n  signal: string | null\n}\nexport interface SSHExecOptions extends SSHExecCommandOptions {\n  stream?: 'stdout' | 'stderr' | 'both'\n}\nexport interface SSHPutFilesOptions {\n  sftp?: SFTPWrapper | null\n  concurrency?: number\n  transferOptions?: TransferOptions\n}\nexport interface SSHGetPutDirectoryOptions extends SSHPutFilesOptions {\n  tick?: (localFile: string, remoteFile: string, error: Error | null) => void\n  validate?: (path: string) => boolean\n  recursive?: boolean\n}\nexport type SSHMkdirMethod = 'sftp' | 'exec'\nexport type SSHForwardInListener = (\n  details: TcpConnectionDetails,\n  accept: AcceptConnection<ClientChannel>,\n  reject: RejectConnection,\n) => void\nexport interface SSHForwardInDetails {\n  dispose(): Promise<void>\n  port: number\n}\nexport type SSHForwardInStreamLocalListener = (\n  info: UNIXConnectionDetails,\n  accept: AcceptConnection,\n  reject: RejectConnection,\n) => void\nexport interface SSHForwardInStreamLocalDetails {\n  dispose(): Promise<void>\n}\nexport class SSHError extends Error {\n  code: string | null\n  constructor(message: string, code?: string | null)\n}\n\nexport class NodeSSH {\n  connection: SSH2.Client | null\n\n  connect(config: Config): Promise<this>\n  isConnected(): boolean\n  requestShell(options?: PseudoTtyOptions | ShellOptions | false): Promise<ClientChannel>\n  withShell(\n    callback: (channel: ClientChannel) => Promise<void>,\n    options?: PseudoTtyOptions | ShellOptions | false,\n  ): Promise<void>\n  requestSFTP(): Promise<SFTPWrapper>\n  withSFTP(callback: (sftp: SFTPWrapper) => Promise<void>): Promise<void>\n  execCommand(givenCommand: string, options?: SSHExecCommandOptions): Promise<SSHExecCommandResponse>\n  exec(\n    command: string,\n    parameters: string[],\n    options?: SSHExecOptions & {\n      stream?: 'stdout' | 'stderr'\n    },\n  ): Promise<string>\n  exec(\n    command: string,\n    parameters: string[],\n    options?: SSHExecOptions & {\n      stream: 'both'\n    },\n  ): Promise<SSHExecCommandResponse>\n  mkdir(path: string, method?: SSHMkdirMethod, givenSftp?: SFTPWrapper | null): Promise<void>\n  getFile(\n    localFile: string,\n    remoteFile: string,\n    givenSftp?: SFTPWrapper | null,\n    transferOptions?: TransferOptions | null,\n  ): Promise<void>\n  putFile(\n    localFile: string,\n    remoteFile: string,\n    givenSftp?: SFTPWrapper | null,\n    transferOptions?: TransferOptions | null,\n  ): Promise<void>\n  putFiles(\n    files: {\n      local: string\n      remote: string\n    }[],\n    { concurrency, sftp: givenSftp, transferOptions }?: SSHPutFilesOptions,\n  ): Promise<void>\n  putDirectory(\n    localDirectory: string,\n    remoteDirectory: string,\n    { concurrency, sftp: givenSftp, transferOptions, recursive, tick, validate }?: SSHGetPutDirectoryOptions,\n  ): Promise<boolean>\n  getDirectory(\n    localDirectory: string,\n    remoteDirectory: string,\n    { concurrency, sftp: givenSftp, transferOptions, recursive, tick, validate }?: SSHGetPutDirectoryOptions,\n  ): Promise<boolean>\n  forwardIn(remoteAddr: string, remotePort: number, onConnection?: SSHForwardInListener): Promise<SSHForwardInDetails>\n  forwardOut(srcIP: string, srcPort: number, dstIP: string, dstPort: number): Promise<Channel>\n  forwardInStreamLocal(\n    socketPath: string,\n    onConnection?: SSHForwardInStreamLocalListener,\n  ): Promise<SSHForwardInStreamLocalDetails>\n  forwardOutStreamLocal(socketPath: string): Promise<Channel>\n  dispose(): void\n}\n```\n\n### Typescript support\n\n`node-ssh` requires extra dependencies while working under Typescript. Please install them as shown below\n\n```\nyarn add --dev @types/ssh2\n# OR\nnpm install --save-dev @types/ssh2\n```\n\nIf you're still running into issues, try adding these to your `tsconfig.json`\n\n```json\n{\n  \"compilerOptions\": {\n    \"moduleResolution\": \"node\",\n    \"allowSyntheticDefaultImports\": true\n  }\n}\n```\n\n### Keyboard-interactive user authentication\n\nIn some cases you have to enable keyboard-interactive user authentication.\nOtherwise you will get an `All configured authentication methods failed` error.\n\n#### Example:\n\n```js\nconst password = 'test'\n\nssh.connect({\n  host: 'localhost',\n  username: 'steel',\n  port: 22,\n  password,\n  tryKeyboard: true,\n})\n\n// Or if you want to add some custom keyboard-interactive logic:\n\nssh.connect({\n  host: 'localhost',\n  username: 'steel',\n  port: 22,\n  tryKeyboard: true,\n  onKeyboardInteractive(name, instructions, instructionsLang, prompts, finish) {\n    if (prompts.length > 0 && prompts[0].prompt.toLowerCase().includes('password')) {\n      finish([password])\n    }\n  }\n})\n```\n\nFor further information see: https://github.com/mscdex/ssh2/issues/604\n\n### License\nThis project is licensed under the terms of MIT license. See the LICENSE file for more info.\n\n[ssh2]:https://github.com/mscdex/ssh2\n","publish_time":1588591879365,"_cnpm_publish_time":1588591879365,"dist-tags":{"beta":"12.0.4-beta1","latest":"13.2.1"}}