Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

sshpk

Package Overview
Dependencies
Maintainers
8
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sshpk

A library for finding and using SSH public keys

  • 1.18.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
20M
decreased by-13.84%
Maintainers
8
Weekly downloads
 
Created

What is sshpk?

The sshpk npm package is a tool for parsing and generating SSH public and private keys. It supports various key types, including RSA, DSA, ECDSA, and Ed25519. It can also handle certificate formats such as SSH, X.509, and others. The package is useful for applications that need to manage or interact with SSH keys and certificates.

What are sshpk's main functionalities?

Parsing SSH keys

This feature allows you to parse SSH public keys from strings or files. The code sample demonstrates how to read an SSH public key from a file and parse it using sshpk.

const sshpk = require('sshpk');
const fs = require('fs');

const keyData = fs.readFileSync('path/to/ssh/key.pub', 'utf-8');
const key = sshpk.parseKey(keyData, 'ssh');

Generating SSH keys

This feature enables the generation of new SSH keys. The code sample shows how to generate a new RSA key with a 2048-bit length.

const sshpk = require('sshpk');

const key = sshpk.generateKey('rsa', 2048);

Converting keys to different formats

This feature allows you to convert SSH keys to different formats, such as PEM. The code sample demonstrates how to parse an SSH key and then convert it to PEM format.

const sshpk = require('sshpk');
const fs = require('fs');

const keyData = fs.readFileSync('path/to/ssh/key.pub', 'utf-8');
const key = sshpk.parseKey(keyData, 'ssh');
const pemKey = key.toBuffer('pem');

Fingerprinting keys

This feature is used to generate a fingerprint of an SSH key, which can be used for verifying identity. The code sample shows how to parse an SSH key and generate its fingerprint using SHA-256.

const sshpk = require('sshpk');
const fs = require('fs');

const keyData = fs.readFileSync('path/to/ssh/key.pub', 'utf-8');
const key = sshpk.parseKey(keyData, 'ssh');
const fingerprint = key.fingerprint('sha256').toString();

Other packages similar to sshpk

FAQs

Package last updated on 19 Oct 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc