Socket
Socket
Sign inDemoInstall

node-ssh

Package Overview
Dependencies
Maintainers
1
Versions
65
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-ssh - npm Package Compare versions

Comparing version 8.0.0 to 9.0.0

lib/cjs/index.js

12

CHANGELOG.md

@@ -0,1 +1,13 @@

#### 9.0.0
* Add support for Putty private key files
* Add `getDirectory` method
* Add `onChannel` support to `execCommand`
* Rename `options.options` in `execCommand` to be `options.execOptions`
* Rename `options.sftpOptions` to `options.transferOptions` in `putFiles`
* Add `withSFTP` and `withShell` methods
* Connection timed out error is now an instance of `SSHError`
* Invalid argument errors are now `AssertionError` instances
* `onKeyboardInteractive` default will only be set if a `config.password` is provided
#### 8.0.0

@@ -2,0 +14,0 @@

20

LICENSE.md
The MIT License (MIT)
Copyright (c) 2014-2016 steelbrain
Copyright (c) 2014-2020 Steel Brain
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

69

package.json
{
"name": "node-ssh",
"version": "8.0.0",
"version": "9.0.0",
"description": "SS2 with Promises",
"main": "lib/index.js",
"main": "lib/cjs/index.js",
"typings": "lib/typings/index.d.ts",
"module": "lib/esm/index.js",
"scripts": {
"test:spec": "ava spec/*-spec.js",
"test:flow": "flow check",
"test:lint": "eslint .",
"test:prettier": "prettier -l '{src,spec}/**/*.js'",
"test": "(npm run test:spec) && (npm run test:flow) && (npm run test:lint) && (npm run test:prettier)",
"prepare": "sb-babel-cli -o lib src",
"watch": "npm run prepare -- -w"
"test": "ava",
"lint": "(tsc -p . --noEmit) && (eslint . --ext .ts) && (prettier --list-different src/*.ts)",
"prepare": "yarn build:clean ; yarn build:cjs ; yarn build:typings",
"build:clean": "rm -rf lib",
"build:cjs": "tsc --module commonjs --target es2018 --outDir lib/cjs",
"build:typings": "tsc --declaration --outDir lib/typings --emitDeclarationOnly"
},
"repository": {
"type": "git",
"url": "https://github.com/steelbrain/node-ssh"
"url": "git+https://github.com/steelbrain/node-ssh.git"
},

@@ -24,3 +25,3 @@ "keywords": [

],
"author": "steelbrain <i@steelbrain.me>",
"author": "steelbrain",
"license": "MIT",

@@ -30,31 +31,37 @@ "bugs": {

},
"files": [
"lib/*"
],
"homepage": "https://github.com/steelbrain/node-ssh#readme",
"devDependencies": {
"@types/shell-escape": "^0.2.0",
"@types/ssh2": "^0.5.43",
"ava": "^3.7.0",
"eslint-config-steelbrain": "^9.0.1",
"node-pty": "^0.9.0",
"ssh2-streams": "^0.4.10",
"ts-node": "^8.8.2",
"typescript": "^3.8.3"
},
"dependencies": {
"p-map": "^3.0.0",
"sb-promisify": "^2.0.1",
"sb-scandir": "^2.0.0",
"make-dir": "^3.1.0",
"sb-promise-queue": "^2.0.0",
"sb-scandir": "^3.0.0",
"shell-escape": "^0.2.0",
"ssh2": "^0.8.7"
"ssh2": "^0.8.9"
},
"devDependencies": {
"@babel/core": "^7.7.7",
"@babel/preset-env": "^7.7.7",
"@babel/preset-flow": "^7.7.4",
"@babel/register": "^7.7.7",
"ava": "^2.4.0",
"babel-eslint": "^10.0.3",
"eslint-config-steelbrain": "^8.0.0-beta1",
"eslint-plugin-flowtype": "^4.5.2",
"flow-bin": "^0.114.0",
"pty.js": "^0.3.1",
"sb-babel-cli": "^2.1.0",
"ssh2-streams": "^0.4.8"
},
"ava": {
"files": [
"spec/*.js"
"test/*-test.ts"
],
"extensions": [
"ts"
],
"require": [
"@babel/register"
"ts-node/register/transpile-only"
]
},
"engines": {
"node": ">= 8"
}
}
Node-SSH - SSH2 with Promises
=========
[![Greenkeeper badge](https://badges.greenkeeper.io/steelbrain/node-ssh.svg)](https://greenkeeper.io/)
Node-SSH is an extremely lightweight Promise wrapper for [ssh2][ssh2].
Node-SSH is an extremely lightweight Promise wrapper for [ssh2][ssh2], Period.
#### Example
```js
var path, node_ssh, ssh, fs
var path, NodeSSH, ssh, fs
fs = require('fs')
path = require('path')
node_ssh = require('node-ssh')
ssh = new node_ssh()
NodeSSH = require('node-ssh')
ssh = new NodeSSH()

@@ -101,38 +99,133 @@ ssh.connect({

```js
type PutFilesOptions = {
sftp: ?Object,
sftpOptions?: Object,
concurrency?: number = 5,
```ts
// API reference in Typescript typing format:
import { Client, ConnectConfig, ClientChannel, SFTPWrapper, ExecOptions } from 'ssh2';
import { Prompt, TransferOptions } from 'ssh2-streams';
// ^ You do NOT need to import these package, these are here for reference of where the
// types are coming from.
declare type Config = ConnectConfig & {
password?: string;
privateKey?: string;
tryKeyboard?: boolean;
onKeyboardInteractive?: (
name: string,
instructions: string,
lang: string,
prompts: Prompt[],
finish: (responses: string[]) => void
) => void;
};
interface SSHExecCommandOptions {
cwd?: string;
stdin?: string;
execOptions?: ExecOptions;
encoding?: BufferEncoding;
onChannel?: (clientChannel: ClientChannel) => void;
onStdout?: (chunk: Buffer) => void;
onStderr?: (chunk: Buffer) => void;
}
type PutDirectoryOptions = {
sftp: ?Object,
sftpOptions?: Object,
concurrency?: number = 5,
recursive?: boolean,
tick?: ((localPath: string, remotePath: string, error: ?Error) => void),
validate?: ((localPath: string) => boolean),
interface SSHExecCommandResponse {
stdout: string;
stderr: string;
code: number | null;
signal: string | null;
}
type ExecOptions = {
cwd?: string,
options?: Object // passed to ssh2.exec
stdin?: string,
stream?: 'stdout' | 'stderr' | 'both',
onStdout?: ((chunk: Buffer) => void),
onStderr?: ((chunk: Buffer) => void),
interface SSHExecOptions extends SSHExecCommandOptions {
stream?: 'stdout' | 'stderr' | 'both';
}
class SSH{
connect(config: SSH2Config): Promise<this>
requestSFTP(): Promise<SSH2SFTP>
requestShell(): Promise<SSH2Shell>
mkdir(path: string, method: 'sftp' | 'exec' = 'sftp', givenSftp?: Object): Promise<string>
exec(command: string, parameters: Array<string>, options: ExecOptions = {}): Promise<Object | string>
execCommand(command: string, options: { cwd: string, stdin: string } = {}): Promise<{ stdout: string, options?: Object, stderr: string, signal: ?string, code: number }>
putFile(localFile: string, remoteFile: string, sftp: ?Object = null, opts: ?Object = null): Promise<void>
getFile(localFile: string, remoteFile: string, sftp: ?Object = null, opts: ?Object = null): Promise<void>
putFiles(files: Array<{ local: string, remote: string }>, options: PutFilesOptions = {}): Promise<void>
putDirectory(localDirectory: string, remoteDirectory: string, options: PutDirectoryOptions = {}): Promise<boolean>
dispose(): void
interface SSHPutFilesOptions {
sftp?: SFTPWrapper | null;
concurrency?: number;
transferOptions?: TransferOptions;
}
interface SSHGetPutDirectoryOptions extends SSHPutFilesOptions {
tick?: (localFile: string, remoteFile: string, error: Error | null) => void;
validate?: (path: string) => boolean;
recursive?: boolean;
}
class NodeSSH {
connection: Client | null;
connect(config: Config): Promise<this>;
requestShell(): Promise<ClientChannel>;
withShell(
callback: (channel: ClientChannel) => Promise<void>
): Promise<void>;
requestSFTP(): Promise<SFTPWrapper>;
withSFTP(
callback: (sftp: SFTPWrapper) => Promise<void>
): Promise<void>;
execCommand(
command: string,
options?: SSHExecCommandOptions
): Promise<SSHExecCommandResponse>;
exec(
command: string,
parameters: string[],
options?: SSHExecOptions & {
stream?: 'stdout' | 'stderr';
}
): Promise<string>;
exec(
command: string,
parameters: string[],
options?: SSHExecOptions & {
stream: 'both';
}
): Promise<SSHExecCommandResponse>;
mkdir(
path: string,
method?: 'sftp' | 'exec',
sftp?: SFTPWrapper | null
): Promise<void>;
getFile(
localFile: string,
remoteFile: string,
sftp?: SFTPWrapper | null,
transferOptions?: TransferOptions | null
): Promise<void>;
putFile(
localFile: string,
remoteFile: string,
sftp?: SFTPWrapper | null,
transferOptions?: TransferOptions | null
): Promise<void>;
putFiles(files: Array<{
local: string;
remote: string;
}>, options?: SSHPutFilesOptions): Promise<void>;
putDirectory(
localDirectory: string,
remoteDirectory: string,
options?: SSHGetPutDirectoryOptions
): Promise<boolean>;
getDirectory(
localDirectory: string,
remoteDirectory: string,
options?: SSHGetPutDirectoryOptions
): Promise<boolean>;
dispose(): void;
}
module.exports = NodeSSH;
```

@@ -139,0 +232,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc