sshrun
Utility to run a script remotely through SSH. Internally uses the node.js SSH implementation SSH2.
Installation
npm install -g sshrunwhich sshrun # /usr/local/bin/sshrun
Usage
$ cat hello.sh#!/bin/bash echo "hello world! I'm $(whoami) on $(hostname). args: '$@'" $ sshrun -i /path/to/key ubuntu@example.com:2222 -- hello.shhello world! I'm ubuntu on example.com. args: ''
A SSH password can also be provided instead. Any args after the script name will be passed to the script.
$ sshrun -p my_password other.example.com -- hello.sh --opt=123 -a 123hello world! I'm ubuntu on example.com. args: '--opt=123 -a 123'
Alternatively, the module can be used directly within node.js.
var sshrun = ; var opts = host: user: 'ubuntu' host: 'example.com' port: 2222 identity: '/path/to/key'; // optional callback called when the script process starts to run.opts { procstdout; procstderr;}; // tell sshrun to not capture any script output in procInfo, for performance// reasons. Useful to use together with the progress() handler to do any// custom manipulation to stdout and stderr.optscaptureOutput = false; ;
License
MIT license - http://www.opensource.org/licenses/mit-license.php