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

ssh-keygen-lite

v1.3.0

Published

Generates SSH key-pairs

Downloads

12,724

Readme

ssh-keygen

npm npm downloads npm bundle size

Generates a SSH key-pair using.

Install

  1. Make sure you have ssh-keygen installed in your machine. Try $ ssh-keygen if you aren't sure
  2. Run npm install ssh-keygen-lite if you're using NPM

Usage

TIP: If you set a non-empty string to the environment variable VERBOSE, you'll enable the verbose mode.
Logs from the lib are prefixed by ssh-keygen-lie: while logs from the binary ssh-keygen are emitted with the prefix ssh-keygen:

// With CommonJS
const path = require('path');
const keygen = require('ssh-keygen-lite');

keygen(
  {
    // sshKeygenPath: 'ssh-keygen',
    location: path.join(__dirname, 'foo_rsa'),
    type: 'rsa',
    read: true,
    force: true,
    destroy: false,
    comment: '[email protected]',
    password: 'keypassword',
    size: '2048',
    format: 'PEM',
  },
  // If you omit this callback function, a Promise will be returned instead!
  function onDoneCallback(err, out) {
    // The error could be related to ssh-keygen binary or file system errors.
    if (err) return console.error('Something went wrong:', err);
    console.log('Keys created!');
    console.log('private key:', out.key);
    console.log('public key:', out.pubKey);
  },
);

Read about the expected types here.

Parameters

  • location: desired location for the key. The public key will be at the location + .pub. Defaults to a file called id_rsa inside a temporary directory
  • type: type of the SSH key that is generated. Defaults to rsa.
  • read: should the callback have the key files read into it. Defaults to true
  • force: destroy pre-existing files with the location name and the public key name. Defaults to true
  • destroy: destroy the key files once they have been read. Defaults to false
  • comment: the comment that should be embedded into the key. Defaults to an empty string
  • password: the password for the key. Falsy values will turn this into an empty string. Defaults to an empty string
  • size: Specifies the number of bits (as string) in the key to create. Defaults to '2048'
  • format: Specify a key format for key generation. Defaults to 'RFC4716'

Promise-based API

NOTE: You'll need NodeJS version 8 or later because it's rely on util.promisify utility.

If you don't supply the second parameter to keygen (ie., the callback), then it will return a Promise that resolves to an plain object with key and pubkey properties.

How it works

The following shell command will get executed:

$ ssh-keygen -t rsa -b 2048 -C "[email protected]" -N "keypassword" -m PEM -f ./foo_rsa
Generating public/private rsa key pair.
Your identification has been saved in ./foo_rsa.
Your public key has been saved in ./foo_rsa.pub.
The key fingerprint is:
02:f7:40:b6:c7:b3:a3:68:16:53:dd:86:63:df:b5:33 [email protected]
The key's randomart image is:
+--[ RSA 2048]----+
|      o          |
|     o + o       |
|    . = O o   .  |
|     + = * . . . |
|    o . S . . E  |
|     + o .     o |
|    + .          |
|   o             |
|                 |
+-----------------+

Note

It is advisable to generate your keys on a machine with a significant random source like one with a mouse/trackpad.

License

ssh-keygen-lite is open source under the MIT license.

All credits go to Eric Vicenti.

Windows

This package bundles binaries for windows. The current version is: 2.4.4.2-rc3