Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including ssh-keygen with all npm packages installed. Try it out:

var sshKeygen = require("ssh-keygen")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

ssh-keygen v0.4.2

Generates SSH key-pairs


Generates a SSH key-pair


  1. Make sure you have ssh-keygen (try $ ssh-keygen if you aren't sure)
  2. npm package install
npm install ssh-keygen

OR download from github and place in ./node_modules


var keygen = require('ssh-keygen');
var fs = require('fs');

var location = __dirname + '/foo_rsa';
var comment = '';
var password = 'keypassword'; // false and undefined will convert to an empty pw

  location: location,
  comment: comment,
    password: password,
  read: true
}, function(err, out){
    if(err) return console.log('Something went wrong: '+err);
    console.log('Keys created!');
    console.log('private key: '+out.key);
    console.log('public key: '+out.pubKey);

The following shell command will get executed:

$ ssh-keygen -t rsa -b 2048 -C "" -N "keypassword" -f ./foo_rsa
Generating public/private rsa key pair.
Your identification has been saved in ./foo_rsa.
Your public key has been saved in ./
The key fingerprint is:
The key's randomart image is:
+--[ RSA 2048]----+
|      o          |
|     o + o       |
|    . = O o   .  |
|     + = * . . . |
|    o . S . . E  |
|     + o .     o |
|    + .          |
|   o             |
|                 |


  • location, desired location for the key. The public key will be at the location + .pub, defaults temp dir
  • read, should the callback have the key files read into it, defaults true
  • force, destroy pre-existing files with the location name and the public key name, defaults true
  • destroy, destroy the key files once they have been read, defaults false
  • comment, the comment that should be embedded into the key, defaults empty
  • password, the password for the key, defaults empty


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


ssh-keygen is open source under the MIT license


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


  • Real tests

Contributors welcome!

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free