Code Monkey home page Code Monkey logo

remote.js's Introduction

Remote.js

Remote.js is a lightweight script that allows you to execute a set of commands on remote servers.

Disclaimer

Using the tool opens up potential security risks to your servers just like any other tool for remote access. Please use at your own risk!

Installation

npm install -g remote.js

Configuration and usage

Before using Remote.js we first need to create a configuration file that looks like:

{
  "port": 3456, // listening port
  "env": { // add your environment variables
  	"NODE_ENV": "production"
  },
  "commands": { // list of commads sets
    "home": {
      "name": "Home Files",
      "commands": [ "ls -l" ]
    },
    "pwd": {
      "name": "Current directory",
      "commands": [ "pwd" ]
    }
  },
  "keys": { // access keys
    "SomeKeyToAccessSomeCommands": [
      "home"
    ],
    "SomeOtherKeyToAccessSomeCommands": [
      "home",
      "pwd"
    ]
  }
}

save your file as config.json for example, then run this command:

remotejs /path/to/your/config.json

Client apps

API

Remote.js uses a simple protocol using socket.io to communicate with remote clients. The following is a simple implementation using socket.io on the client side:

Connect

var socket = io.connect('http://your_host_or_ip:3456');

Authenticate

socket.on('connect', function() {
  socket.emit('auth', server.key, function(result){
    if(result.success){
      result.commands; // contains a list of your commands as defined in your config file
    }

    if(result.error){
      // handle the error
    }
});

Run commands

socket.emit('command', command, function(res){
  var commandId = res.command_id;
});
    
socket.on('command_out', function(co) {
  console.log(co.out);
});

socket.on('command_err', function(ce) {
  console.log(ce.err);
});

socket.on('command_end', function(cmdId) {
  console.log("Finished running the command");
});

remote.js's People

Contributors

abdelilah avatar

Stargazers

Li Yi avatar

Watchers

 avatar James Cloos avatar

Forkers

binaryecho

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.