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

pusshkey

v0.1.3

Published

Push/remove public SSH keys to/from remote hosts

Downloads

11

Readme

pusshkey

Basic CLI (and Node module) to push SSH keys to remote hosts. Add or remove a public key from several hosts in one shot.

Here's the scenario: You already have public key authentication to a set of remote hosts (on-premise VMs or AWS EC2 instances) and now you need to give someone else access. Full-blown configuration management might be overkill - you just need to propagate someone else's key. Ok, you can either write up a simple bash script or... do it manually? Yuck. Then what do you do when someone leaves the company/project and you now need to remove that person's key?

Enter pusshkey. A simple tool for a simple job. Install via npm, optionally configure a group of hosts in pusshkey.json, and pusshkey add or pusshkey rm.

Install

$ npm install -g pusshkey

Usage

Add key to one or more hosts. Will only add the key if it does not already exist. :thumbsup:

$ pusshkey [options] add <key> <host> [hosts...]

Remove key from one or more hosts.

$ pusshkey [options] rm <key> <host> [hosts...]

Note that a <key> is the public key to add or remove, either as a file reference or as the public key value itself. A <host> is either a hostname, IP, or alias. See Configuration below about using aliases to represent a set of hosts.

Also run pusshkey -h or pusshkey for help content and pusshkey -V to output the installed version.

Options

-u <user>, --user <user>

The SSH user on the remote host(s). This will be used for authentication in order to access the remote hosts, and the key that you're pushing will go in the authorized_keys file that belongs to this user.

Default value is either 1) the user specified in the pusshkey.json config file (see Configuration below) or 2) the current user. Run pusshkey -h to see which user will be used as default.

-i <identity>, --identity <identity>

The identity file (private key) used for public key authentication against the remote host(s). This file represents your credentials (key and associated passphrase). This is the key you want to add to ssh-agent via ssh-add <key> before running pusshkey (see Notes below).

Default value is either 1) the identity specified in the pusshkey.json config file (see Configuration below) or 2) the default for the ssh program (typically ~/.ssh/id_rsa). Run pusshkey -h to see which identity file will be used as default. A value of '' equates to the default for the ssh program.

Examples

# Add some_key to your-server
$ pusshkey add ~/.ssh/some_key.pub your-server

# Add some_key to multiple hosts
$ pusshkey add ~/.ssh/some_key.pub your-server-1 your-server-2 192.168.0.1 ec2-1-2-3-4.compute-1.amazonaws.com

# Add key_in_cwd.pub to your-server and authenticate using foo user and x_id_rsa private key
$ pusshkey add key_in_cwd.pub your-server -u foo -i ~/.ssh/x_id_rsa

# Remove old_key from your-server
$ pusshkey rm old_key.txt your-server

Also see Notes below about using ssh-agent (before you run pusshkey) to make your life easier.

Configuration

The big win here is the ability to predefine host aliases, which can represent one or more actual hostnames. You can also specify which user and identity that ssh should use (instead of using the -u and -i options every time).

Define a pusshkey.json file in the current working directory that contains the following (all entries are optional):

{
  "hosts": {
    "dev-alias": [ "dev-server-1", "dev-server-2", "dev-server-N" ],
    "prd-alias": [ "prd-server-1", "prd-server-2", "prd-server-3", "prd-server-N" ],
    "all": [ "dev-alias", "prd-alias" ]
  },
  "user": "foo",
  "identity": "~/.ssh/foo_id_rsa"
}

Each "hosts" entry defines a host alias, and you can reference other aliases in the array. Circular references are supported, though I'm not sure why you would need them. It's also ok if you use the same host in multiple aliases - pusshkey will detect this and will only access each host once per execution.

The config above would let you run simple commands like:

$ pusshkey add new_key.pub dev-alias
$ pusshkey rm old_key.pub all

To propagate a key to several hosts in one execution for the foo user, using foo_id_rsa for authentication.

The configuration file MUST be in the current working directory, and it MUST be named pusshkey.json.

Notes

  • Currently requires the ssh program. If you're on Windwos, try installing msysgit first.
  • To avoid password/passphrase prompts, make sure ssh-agent is running and you have added your private key via ssh-add before using pusshkey. Should be as simple as:
$ ssh-agent
$ ssh-add <key>
  • To check if your key has been added to ssh-agent, run ssh-add -l.

API

Coming soon.