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 debug: true // optional console: console // optional, 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;
notes:
- optional for
exec()
:canFail: true
, continue if the command fails - optional for
writeFile()
:flags: 'flags'
, see here, e.g.'w'
for overwrite,'a'
for append (on'a*'
flags, pointer is automatically positioned to the end of the file) - optional for
writeFile()
:mode: 0666
, see here (only the setable ones)
use 2
var opts = host: 'myhost' port: 22 username: 'ubuntu' privateKey: fs debug: true // optional console: console // optional, allows logger overriding; sshclient;
notes:
- optional for
writeFile()
:flags
andmode
(sig:writeFile(path, bodyOrBuff, flags, mode, cb)
- see use 1 for explanation