package
cli utility for running remote commands over ssh
npm install sshoutGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
Estimated unpacked size across 6 packages.
99.1 kB
Includes dependencies.
Command line utility for running remote commands over ssh.
$ npm install -g sshoutAdds the sshout command when installed globally. Takes everything after sshout and runs that command from a hosted folder on the server.
require()'able so you can call it from node.Lets create an example environment where we can execute remote commands over ssh. We need the following:
sshout defining user, host, port (optional) and scripts (optional).Lets assume the scripts folder on the server is located in the user $HOME folder and called myscripts. Lets also assume the scripts are hosted on the server example.com and that the user is ubuntu. We start by creating a configuration file ~/.sshoutrc, which can be either in json or ini format.
We will pick json for our configuration:
{
"host": "example.com",
"user": "ubuntu",
"scripts": "myscripts"
}Lets add the following script on the server and lets call it beepboop:
#!/bin/bash
echo 'beep boop'We can now run this script remotely with the following command:
$ sshout beepboop
beep boopNo arguments or list lists available commands:
$ sshout
The following commands are available:
beepboopThis module exports a constructor function, which returns a function for running remote ssh commands programmatically.
var ssh = require('sshout')([config])config (object) Optional configuration object. See configuration below. If set, overrides configuration provided by rc.ssh(cmd[, callback])cmd (string) Command to execute on the server.callback (function) Optional callback. Called with an Error object if the remote command failed.var ssh = require('sshout')({
host: 'example.com',
user: 'ubuntu',
port: 22,
scripts: 'myscripts',
key: 'mykeyfile'
})
ssh('beepboop', function (err) {})
ssh('somescript arg1 arg2 --flag=value', function (err) {})Configuration for sshout is powered by rc and takes the following properties:
user (string): Login as this user.host (string): Server host.port (number, default: 22): Server port.scripts (string, default: scripts): Path to the folder hosting the commands, relative to $HOME for the current user. It can also be an absolute path.key (string, optional): Absolute path to key file name. Using ~ will be expanded to the users home folder.See this for more information on how rc handles file locations and this for information on the different file formats.
The following extra environment variables will be passed for scripts to use:
SCRIPTS: The path of the scripts folderralphtheninja
ralphtheninja@riseup.net