Remote.js is a lightweight script that allows you to execute a set of commands on remote servers.
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!
npm install -g remote.js
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
- Chrome Extension (beta)
- Android App (coming soon)
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:
var socket = io.connect('http://your_host_or_ip:3456');
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
}
});
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");
});