0.0.4 • Published 11 years ago

sshclient v0.0.4

Weekly downloads
7
License
-
Repository
github
Last release
11 years ago

sshclient

a tiny, simple but durable wrapper for the ssh2 node.js lib.

early version, only deployment related commands are supported: writeFile() and exec().

for the (optional) use of _x(), see laeh2.

use 1

var opts = {

    host: 'myhost',
    port: 22,
    username: 'ubuntu',
    privateKey: fs.readFileSync('./somekey.pem'),

    debug: true, // optional
    console: console, // allows logger overriding

    session: [
        { op: 'writeFile', path: '/mydir/myfile.txt', body: 'my utf8 body, or a buffer\n' },
        { op: 'exec', command: 'chmod o+w /mydir/myfile.txt' }
    ]
};

sshclient.session(opts, _x(cb, true, function(err) {
    console.log('done');
    cb();
}));

use 2

sshclient.session(opts, _x(cb, true, function(err, ses) {
   
    async.series([

        _x(null, false, function(cb) {
            ses.writeFile('/mydir/myfile.txt', 'my utf8 body, or a buffer\n', cb);
        }),
        
        _x(null, false, function(cb) {
            ses.exec('chmod o+w /mydir/myfile.txt', cb);
        }),

    ], _x(cb, false, function(err) {
        ses.quit(); // need to close the session here on both error and success
        cb(err);
    }));

}));
0.0.4

11 years ago

0.0.3

11 years ago

0.0.2

11 years ago

0.0.1

11 years ago