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

simple-ssh-commands

v0.4.2

Published

A NPM package to execute simple tasks like a git pull via SSH

Downloads

109

Readme

Simple SSH Commands

Build Status

This package aims to make executing simple SSH Commands like a git pull on your server as easy as possible. It also has a better approach to handle passwords than other packages.

All you will need is a config file with credentials (username and host) and your commands.

How to install and prepare

npm install simple-ssh-commands --save-dev

Then create a .simple-ssh-commands file in the same folder as your package.json. The content of the file should be valid JSON. Here is an example:

// .simple-ssh-commands file
{
    "username": "Test",
    "host": "example.com",
    "commands": ["cd /var/www/website", "ls -la"]
}

And that's basically it. You can run the commands by calling the binary directly:

node_modules/.bin/simple-ssh-commands

or add a script to your package.json like so:

// package.json
{
    ...
    "scripts": [
        ...
        "execute-ls-on-server": "simple-ssh-commands",
        ...
    ]
    ...
}

and then run npm run execute-ls-on-server or whatever you named you script.

Password handling

Passwords can be added to your .simple-ssh-commands file. This is only a good idea if you do not commit this file though.

This Package supports two other ways to handle your passwords:

  1. If you don't add it to your .simple-ssh-commands file you will be prompted every time to enter it when you want to run the commands. Just enter password and the commands will be run.

  2. If this process is to cumbersome for you, there is the possibility to create a .env file (if you don't already have one) in your projects root. You can add the key value pair SSC_PASSWORD=12345 (with your password) to it. The password will be taken from there if the key is found.

Multiple connections and commands

This package supports multiple connections or different commands for the same connection that can be placed in an Array in the .simple-ssh-commands file.

// .simple-ssh-commands file
[
    {
        "key": "show-content",
        "username": "name",
        "host": "example.com",
        "commands": ["cd /var/www/website", "ls -la"]
    },
    {
        "key": "git-pull",
        "username": "name",
        "host": "example.com",
        "commands": ["cd /var/www/website", "git pull"]
    }
]

If you still call the simple-ssh-commands command without an argument the first key of the array will be used. But you are now able to pass the name of the key that should be run. Here is an example of a package.json file using the feature.

// package.json
{
  "name": "test",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "show-content": "simple-ssh-commands show-content",
    "git-pull": "simple-ssh-commands git-pull"
  },
  "author": "Simon vom Eyser",
  "license": "ISC"
}

Passwords in your .env file will need the commands name as a postfix (uppercase with underscores for dashes) though.

SSC_PASSWORD_SHOW_CONTENT=12345
SSC_PASSWORD_GIT_PULL=12345

Roadmap

If somebody is interested in this let me know, there is a lot that could be optimized about this package!

  • Make it possible to provide host and username in an .env file so these things don't end up in version control
  • Add the possibility to pass a SSH-Key and use that
  • Improve server output display since it is still quite confusing.