Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
setup nodejs (git, nvm, npm, forever) on remote machine
// working NodeSSH can be used by installing via npm this
var SSHClient = require("NodeSSH");
var Expect = require('node-expect');
var password = "password";
var ssh=new SSHClient("host","root", "rootPassword");
parser = new Expect();
parser.debug = 5;
.sync() // synchronous conversation.
.expect(null,true) // the conversation trigger starts the expect. no need to expect anything more.
.send("apt-get update; apt-get -y install rsync build-essential g++ curl libssl-dev apache2-utils git-core\n")
.expect("# ")
.send("useradd -g admin -s /bin/bash -m nodejs\n")
.expect("# ")
.send("passwd nodejs\n")
.expect("# ")
.send("su - nodejs\n")
.conversation(/\$ /)
.send("git clone git:// ~/.nvm\n")
.expect(/\$ /)
.send(". ~/.nvm/; nvm install v0.4.11\n")
.expect(/\$ /)
.send(". ~/.nvm/; nvm use v0.4.11; npm install forever -g\n")
.expect(/\$ /)
ssh.on('close',function(addr) {
console.log('Disconnected from '+addr);
ssh.connect(function(addr) {
console.log('Connected to '+addr);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment