ssh-key-files

1.0.0 • Public • Published

ssh-key-files Build Status

Return an object containing ssh-keyfile pairs of the current user

Install

$ npm install ssh-key-files

Usage

const sshKeyFiles = require('ssh-key-files');

sshKeyFiles();
//=> {unicorn: '/Users/dr-evil/.ssh/unicorn'}

// Search a custom directory instead
sshKeyFiles('/temp');
//=> {garbage: '/temp/garbage'}

API

sshKeyFiles([dir])

Searches at the users ssh-directory for private/public key-file pairs. It estimates the given file pairs share the same basename where the private name has no file-extension and the public keyfile ends with .pub.

The result consists of private keyfile-basename / private keyfile-path pairs, if the private as well as the public files exist.

Example:

{
  github: '/Users/unicorn/.shh/github',
  gitlab_rsa: '/Users/unicorn/.shh/gitlab_rsa'
}

⚠️ The file permissions are not checked.

The public keyfile can be easily derived by adding the .pub-extension manually:

const keyFiles = sshKeyFiles();
const privateKeyFile = keyFiles.unicorn; //=> /Users/dr-evil/.ssh/unicorn
const publicKeyFile = `${privateKeyFile}.pub`; //=> /Users/dr-evil/.ssh/unicorn.pub

dir (optional)

Type: string

Alternative path to search for files with a corresponding .pub-file. Defaults to the users .ssh-folder (located at the users os-specific home directory).

License

MIT © Florian Breisch

Readme

Keywords

Package Sidebar

Install

npm i ssh-key-files

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

4.2 kB

Total Files

4

Last publish

Collaborators

  • florianb