# nodemiral

> Server Automation for NodeJS over SSH

Latest version **1.1.1** (published 2015-09-25) · 0 weekly downloads

## Install

```sh
npm install nodemiral
pnpm add nodemiral
yarn add nodemiral
bun add nodemiral
```

## 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 | 1.1.1 |
| Published | 2015-09-25 |
| First published | 2013-08-09 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 7 |
| Known vulnerabilities | 0 (+10 in 4 direct dependencies) |
| Install scripts | no |
| Maintainers | arunoda |

## Links

- npm: https://www.npmjs.com/package/nodemiral
- npm.io page: https://npm.io/package/nodemiral

## Dependencies (7)

- [ejs](https://npm.io/package/ejs.md) 0.8.x
- [ssh2](https://npm.io/package/ssh2.md) 0.4.6
- [async](https://npm.io/package/async.md) 0.9.0
- [debug](https://npm.io/package/debug.md) 0.7.x
- [colors](https://npm.io/package/colors.md) 0.6.x
- [progress](https://npm.io/package/progress.md) 1.1.5
- [underscore](https://npm.io/package/underscore.md) 1.8.x

## Recent versions

- 1.1.1 (latest) — 2015-09-25
- 1.1.0 — 2015-05-15
- 0.5.0 — 2015-05-15
- 0.4.1 — 2015-05-14
- 1.0.3 — 2015-05-14
- 1.0.2 — 2015-05-14
- 0.4.0 — 2015-05-14
- 1.0.1 — 2015-04-25
- 1.0.0 — 2015-04-25
- 0.3.11 — 2014-05-11
- 0.3.10 — 2014-05-07
- 0.3.9 — 2014-01-08
- 0.3.8 — 2014-01-08
- 0.3.7 — 2014-01-08
- 0.3.6 — 2013-11-22
- … 22 more at https://npm.io/package/nodemiral/versions

## README

# nodemiral (node + admiral) [![Build Status](https://travis-ci.org/arunoda/nodemiral.png?branch=master)](https://travis-ci.org/arunoda/nodemiral)
### Server Automation for NodeJS over SSH

## Install
~~~js
npm install nodemiral
~~~

## Features

* Support connecting to any unix remote server
* Authenticate with password(using [`sshpass`](http://sourceforge.net/projects/sshpass/)) or with a `pem` file
* Can work with multiple servers at once
* Supports, `copy`, `execute` and `executeScript` at core methods
* Familiar NodeJS API

## Example
~~~js
var nodemiral = require('nodemiral');
var session = nodemiral.session('hostname', {username: 'root', password: 'password'});

session.execute('uname -a', function(err, code, logs) {
  console.log(logs.stdout);
});
~~~

## API

### Session

Create a session to a remote server. You can invoke following methods after created a session

    @param hostname - hostname or ip addess
    @param auth - object containing following fields: `username` and (`password` or `pem`)
    @param options - object of options described below
    nodemiral.session(hostname, auth, options);

`options`:

* `ejs` - ejs options with `ejs` fields
* `ssh` - object whose key and value will be passed as `-o key:value` to any ssh session. For example `{ 'StrictHostKeyChecking': 'no', 'UserKnownHostsFile': '/dev/null' }`

### Session Methods

#### execute
execute given shell command on the remote server

    @param shellCommand - shellCommand
    @param options - {onStdout, onStderr}
    @param callback - callback containing following parameters
      err - err if exists
      code - status code of the ssh process
      logs - {stdout: 'stdout logs', stderr: 'stderr logs'}
    session.execute(shellCommand, callback);

#### executeScript
execute a local shell script in the remote server. You can template shell script with [EJS](https://github.com/visionmedia/ejs).

    @param localScriptFile - localScriptFile
    @param options.vars - variables to the template if uses ejs in the script
    @param callback - callback containing following parameters
      err - err if exists
      code - status code of the ssh process
      logs - {stdout: 'stdout logs', stderr: 'stderr logs'}
    session.executeScript(localScriptFile, options, callback);

#### copy
copy a file from local machine to the remote machine. Supports binary files too. Support EJS templating with non-binary files

    @param localFile - localFile
    @param remoteFileLocation - remoteFileLocation
    @param options.vars - templateVars
    @param optiosn.progressBar - show progress bar
    @param callback - callback containing following parameters
      err - err if exists
      code - status code of the ssh process
      logs - {stdout: 'stdout logs', stderr: 'stderr logs'}
    session.copy(localFile, remoteFileLocation, options, callback)

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