Giter VIP home page Giter VIP logo

nodemiral's Introduction

nodemiral (node + admiral) Build Status

Server Automation for NodeJS over SSH

Install

npm install nodemiral

Features

  • Support connecting to any unix remote server
  • Authenticate with password(using 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

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.

@param localScriptFile - localScriptFile
@param templateVars - variables to the template if uses ejs in the script
@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.executeScript(localScriptFile, templateVars, 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 - {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.copy(localFile, remoteFileLocation, templateVars, callback)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.