Gathering detailed insights and metrics for ssh2-exec
Gathering detailed insights and metrics for ssh2-exec
Gathering detailed insights and metrics for ssh2-exec
Gathering detailed insights and metrics for ssh2-exec
ssh2
SSH2 client and server modules written in pure JavaScript for node.js
ssh2-connect
Callback-based api behind ssh2 to open an SSH connection
@electerm/ssh2
SSH2 client and server modules written in pure JavaScript for node.js
ssh2-no-cpu-features
SSH2 client and server modules written in pure JavaScript for node.js
Transparent use of `child_process.exec` and `ssh2.prototype.exec`
npm install ssh2-exec
Typescript
Module System
Min. Node Version
Node Version
NPM Version
TypeScript (96.23%)
JavaScript (3.77%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
7 Stars
219 Commits
2 Forks
9 Watchers
2 Branches
14 Contributors
Updated on Oct 24, 2024
Latest Version
0.8.4
Package Id
ssh2-exec@0.8.4
Unpacked Size
75.68 kB
Size
9.47 kB
File Count
15
NPM Version
10.8.2
Node Version
20.18.0
Published on
Oct 24, 2024
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
25
The Node.js ssh2-exec
package extends the ssh2
module to provide transparent usage between the child_process.exec
and ssh2.prototype.exec
functions. It was originally developped for and is still use by Nikita to run actions both locally and over SSH.
This is OSS and licensed under the MIT license.
1npm install ssh2-exec
ssh2-exec
module usageThe default module expose an API similar to the native NodeJS API. Its signature is:
exec(sshOrNull, command, [options], [callback])
Or
exec(options, [callback])
Like in the native NodeJS API, the callback is not required in case you wish to work with the returned child stream. The "sshOrNull" and "command" arguments are also facultative because they could be provided respectively as the "ssh" and "command" property of the options object.
Valid options
properties are:
ssh
command
cwd
end
env
pty
cwd
uid
gid
See the ssh2 and ssh2-connect modules on how to create a new SSH connection.
ssh2-exec/promises
module usageNote, until version 0.7.3
, the module was named ssh2-exec/promise
. The promise
resolution is still working. However, it will be removed in an upcoming version in favor of ssh2-exec/promises
in order to be consistent with the Node.js node:fs/promises
module.
The promise module is an alternative to the callback usage. Like with the callback, use it if stdout
and stderr
are not too large and fit in memory.
const {stdout, stderr, code} = await exec(sshOrNull, command, [options])
Or
const {stdout, stderr, code} = await exec(options)
If the exit code is not 0
, the thrown error object contains the stdout
, stderr
, and code
properties.
A command, a configuration object and a callback:
1import { connect } from "ssh2-connect"; 2import { exec } from "ssh2-exec"; 3connect({ host: localhost }, (err, ssh) => { 4 exec("ls -la", { ssh: ssh }, (err, stdout, stderr, code) => { 5 console.info(stdout, stderr, code); 6 }); 7});
A configuration object with a ssh2 connection and working a the return child object:
1import { connect } from "ssh2-connect"; 2import { exec } from "ssh2-exec"; 3connect({ host: localhost }, function (err, ssh) { 4 child = exec( 5 { 6 command: "ls -la", 7 ssh: ssh, 8 }, 9 function (err, stdout, stderr, code) { 10 console.info(stdout); 11 }, 12 ); 13 child.stdout.on("data", function (data) { 14 console.info(data); 15 }); 16 child.stderr.on("data", function (data) { 17 console.error(data); 18 }); 19 child.on("exit", function (code) { 20 console.info("Exit", code); 21 }); 22});
Tests are executed with mocha. To install it, simple run npm install
, it will install mocha and its dependencies in your project "node_modules" directory.
To run the tests:
1npm test
Versions are incremented using semantic versioning. To create a new version and publish it to NPM, run:
1npm run release
The publication is handled by the GitHub action.
The project is sponsored by Adaltas based in Paris, France. Adaltas offers support and consulting on distributed systems, big data and open source.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
packaging workflow detected
Details
Reason
5 existing vulnerabilities detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 3
Details
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More