# ssh-exec

> Execute a script over ssh using Node.JS

Latest version **2.0.0** (published 2016-01-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install ssh-exec
pnpm add ssh-exec
yarn add ssh-exec
bun add ssh-exec
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2016-01-20 |
| First published | 2013-11-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 124 |
| Author | Mathias Buus |
| Maintainers | mafintosh |
| Keywords | ssh, stream, duplex, exec, connection |

## Links

- npm: https://www.npmjs.com/package/ssh-exec
- Repository: https://github.com/mafintosh/ssh-exec
- Issues: https://github.com/mafintosh/ssh-exec/issues
- npm.io page: https://npm.io/package/ssh-exec

## Dependencies (3)

- [once](https://npm.io/package/once.md) ^1.3.3
- [ssh2](https://npm.io/package/ssh2.md) ^0.4.8
- [duplexify](https://npm.io/package/duplexify.md) ^3.2.0

## Alternatives

- [byte-size](https://npm.io/package/byte-size.md) — 2.1M weekly downloads
- [speed-limiter](https://npm.io/package/speed-limiter.md) — 16.0K weekly downloads
- [@powersync/node](https://npm.io/package/@powersync/node.md) — 10.9K weekly downloads
- [@ledgerhq/coin-cardano](https://npm.io/package/@ledgerhq/coin-cardano.md) — 1.0K weekly downloads
- [@jayesol/jayeson.lib.streamfinder](https://npm.io/package/@jayesol/jayeson.lib.streamfinder.md) — 1.0K weekly downloads

## Recent versions

- 2.0.0 (latest) — 2016-01-20
- 1.4.0 — 2016-01-02
- 1.3.0 — 2015-07-09
- 1.2.0 — 2015-06-12
- 1.1.1 — 2015-06-07
- 1.1.0 — 2015-04-13
- 1.0.0 — 2015-04-10
- 0.3.3 — 2015-02-16
- 0.3.2 — 2014-01-24
- 0.3.1 — 2013-12-07
- 0.2.0 — 2013-11-26
- 0.1.5 — 2013-11-25
- 0.1.4 — 2013-11-25
- 0.1.3 — 2013-11-20
- 0.1.2 — 2013-11-20
- … 2 more at https://npm.io/package/ssh-exec/versions

## README

# ssh-exec

Execute a script over ssh using Node.JS and pipe to and from it

It is available through npm

```
npm install ssh-exec
```

It is written in plain Javascript and uses [ssh2](https://github.com/mscdex/ssh2) for all the heavy lifting.

## Usage

``` js
var exec = require('ssh-exec')

// using ~/.ssh/id_rsa as the private key

exec('ls -lh', 'ubuntu@my-remote.com').pipe(process.stdout)

// or using the more settings

exec('ls -lh', {
  user: 'ubuntu',
  host: 'my-remote.com',
  key: myKeyFileOrBuffer,
  password: 'my-user-password'
}).pipe(process.stdout)

// or if you want to pipe some data to the remote process

process.stdin
  .pipe(exec('echo try typing something; cat -', 'ubuntu@my-remote.com'))
  .pipe(process.stdout)
```

Optionally there is a callback api as well

``` js
exec('ls -lh', 'ubuntu@my-remote.com', function (err, stdout, stderr) {
  console.log(err, stdout, stderr)
})
```

## License

MIT

---
_Source: https://npm.io/package/ssh-exec · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
