npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

sshout

v1.1.0

Published

cli utility for running remote commands over ssh

Downloads

10

Readme

sshout

Command line utility for running remote commands over ssh.

Install

$ npm install -g sshout

Usage

Adds the sshout command when installed globally. Takes everything after sshout and runs that command from a hosted folder on the server.

Features

  • Secure through ssh (well duh).
  • require()'able so you can call it from node.
  • Since the client is very dumb and the server has all the logic, there is no need to keep clients up to date.
  • Scripts can be written in any scripting language.

CLI

Lets create an example environment where we can execute remote commands over ssh. We need the following:

  • A folder with some scripts, accessible over ssh.
  • A configuration file for 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 boop

No arguments or list lists available commands:

$ sshout
The following commands are available:
 beepboop

API

This 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.

Example

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

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.

Scripts environment

The following extra environment variables will be passed for scripts to use:

  • SCRIPTS: The path of the scripts folder