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

pubkey-collecter

v0.0.5

Published

Collect SSH Public keys from Git Hosting Services.

Downloads

9

Readme

pubkey-collecter

Docker npm GitHub

🗝🦅 Collect SSH Public keys from Git Hosting Services Github, Gitlab.

General Usecase

  • Get key List
  • Generate authorized_keys

Usage

General usage

$ pubkey-collecter --<Options> [HostingService]:<account> ...
      Options:
        help                            show usage
        (github|gitlab|custom-service)  search as default (default: github)
        raw                             Raw string output (useful for getting authorized_keys)

e.g.) pubkey-collecter --github --raw mkontani gitlab:niconico-pun
  • Use -- prefix for options
  • Use space separation for multiple accounts specification

See the detail below desc.

Use as Container CLITOOL

You can run docker container like following.

$ docker run mkontani/pubkey-collecter <your account1> <your account2> ...
{
  'github:<your account1>': [
    {
      id: 34508497,
      key: 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQC2X8izVqnzSq61B9rLAMdqOBA2jU1QTZZF6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+gsxGw1+mEc0S9rl0GVhOHOvslTFHv7KAYGWY5++Lb3kZwGCf2f5Uvgswc7XcbxyzVm7pLDHwBF4sVl3wvAI8sUanJWUGS59OgkLwDWqH97+AwRlOvQnK+K3kK98Lk/7OzL7E+qRnoFuSIQfZo2MyNjxs+R08I7SdR/xDLBc2OP5IgSyN97PNsRc3YwQdMkw/un5j/J3Mj2pEVJjaZL3k4g+cdD9UJ12ZZFkW5JIwfYMrACFlijfOpPfQjd/z+5g+LbmL7QadHcq/K4kJscHGUKk7u97aZEWvOziRF62wVjgG79Npw1ROwtMnnWWrYLhxbMb+Tpys17SVwXsUFfA3mjMLiIEtcD6RQ=='
    }
  ]
  ...
}

If you can get OpenSSH authorized_keys format, add --raw option like below.

$ docker run mkontani/pubkey-collecter --raw <your account1> <your account2> ...
# github:<your account1>
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQC2X8izVqnzSq61B9rLAMdqOBA2jU1QTZZF6Nu4/lS2g/8X5IMtp750m4pEyimxe8FAQsXv7eJUupfUYxhXStDtX/77KAeV9T0qKdnduX/ZH4ugf7wQshRuz4sJFPkNW1GZyTUAlkNuJnHlqaRqn/8MHcDD3NWHM1QgdTP5Jrg+XO1V28kbBRIP5gcSCGgE4HLdJ9zFrc/aRLxzzXTvlN+shcOHX0NcqJEgEAV6Z7O+R8j5tOkYAJPxW9lhBqDFvxWdaLSHPIdDpb8IgtMpIlsgRWhjM0PcHmNBM00tvxWDr7Fc5xOwhFrVFcgmwEU4fZktis9Sz8W1+gsxGw1+mEc0S9rl0GVhOHOvslTFHv7KAYGWY5++Lb3kZwGCf2f5Uvgswc7XcbxyzVm7pLDHwBF4sVl3wvAI8sUanJWUGS59OgkLwDWqH97+AwRlOvQnK+K3kK98Lk/7OzL7E+qRnoFuSIQfZo2MyNjxs+R08I7SdR/xDLBc2OP5IgSyN97PNsRc3YwQdMkw/un5j/J3Mj2pEVJjaZL3k4g+cdD9UJ12ZZFkW5JIwfYMrACFlijfOpPfQjd/z+5g+LbmL7QadHcq/K4kJscHGUKk7u97aZEWvOziRF62wVjgG79Npw1ROwtMnnWWrYLhxbMb+Tpys17SVwXsUFfA3mjMLiIEtcD6RQ==
...

// e.g.) add to authorized_keys
$ docker run mkontani/pubkey-collecter --raw <your account1> <your account2> ... >> $PWD/.ssh/authorized_keys

Use as NPM CLITOOL

// install cli
$ npm install -g pubkey-collecter

// or install locally
$ npm install pubkey-collecter


// exec (same as container case)
$ pubkey-collecter <youraccount1> <youraccount2>

// or exec locally
$ ./node_module/.bin/pubkey-collecter <youraccount1> <youraccount2>

Use as NPM Module

// import module
const { collect, parseRaw } = require('pubkey-collecter')

// get pubkeyList
const pubkeys = await collect(['github:octcat', 'gitlab:youraccount'])
console.log(pubkeys) // output is the same as abobe docker case

// get rawString
const pubRaw = parseRaw(pubkeys)
console.log(pubRaw) // output is the same as abobe docker case

Options

|option|desc| |:--:|:--| |--help| Show usage | |--github|Search github service as default (used as default)| |--gitlab|Search github service as default | |--(custom Hosting Service)|Search custom Service as default (see detail customize section)| |--raw| Raw string output (useful for getting authorized_keys)|

Customize

You can customize hosting services by adding hosting.json like following. Set {id} as account(id) part.


    "custom-service1":{
        "api": "https://custom1.github.com/api/v4/users/{id}/keys"
    },
    "custom-service2":{
        "api": "https://custom2.github.com/api/v4/users/{id}/keys"
    },

After editting hosting.json, you can specify like below.

// set default search option
$ pubkey-collecter --custom-service1 mkontani

// or specify prefix
$ pubkey-collecter custom-service2:mkontani

You can set custom config file path by setting HOSTING_CONF env.