Giter Club home page Giter Club logo

ssh-key-decrypt's Introduction

ssh-key-decrypt

Decrypt encrypted ssh private keys

USAGE

var decrypt = require('ssh-key-decrypt');

// you have to actually know this already of course.
var passphrase = 'hoohah';

var fs = require('fs');
var path = require('path');

var keyfile = path.resolve(process.env.HOME, '.ssh', 'id_rsa');
var fileData = fs.readFileSync(keyfile, 'ascii');

var key = decrypt(fileData, passphrase);

// now key is the decoded data as a buffer
// You can also optionally pass in an output encoding

var b64Key = decrypt(fileData, passphrase, 'base64');

decrypt(data, passphrase, [outEnc='buffer'])

Data can be either a string or a buffer. It is the contents of the key file.

If the file is not encrypted, then the passphrase doesn't matter.

If the file is encrypted, then it'll decrypt it.

Either way, the data is returned in the output encoding specified.

WARNING

This module is synchronous, as it performs no I/O. However, it can potentially be kind of slow, since it does a bunch of crypto and hashes, so do not call it often or in hot code paths.

Also, as this is crypto, and thus only either exactly right or extremely wrong, it throws if anything unexpected is encountered.

Supported Ciphers

  • des3, aka DES-EDE3-CBC
  • des, aka DES-CBC
  • aes128, aka AES-128-CBC
  • aes192, aka AES-192-CBC
  • aes256, aka AES-256-CBC

The cipher type is determined from the file. You do not have to specify this.

ssh-key-decrypt's People

Contributors

isaacs avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.