Skip to content

Instantly share code, notes, and snippets.

@developerworks
Forked from appinsanity/ssh-keygen.js
Created August 13, 2014 16:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save developerworks/87a68d2a82fddbc4fc34 to your computer and use it in GitHub Desktop.
Save developerworks/87a68d2a82fddbc4fc34 to your computer and use it in GitHub Desktop.
var spawn = require('child_process').spawn,
sys = require('sys');
function createSSH(passphrase, path, name) {
var ssh = spawn('ssh-keygen', ['-trsa', '-N \''+ passphrase +'\'', '-f ' + name], { cwd:path, env: process.env, customFds: [-1, -1, -1]})
ssh.on('exit', function (code, signal) {
process.exit();
});
ssh.stdout.on('data', function (out) {
process.stdout.write(out);
});
ssh.stderr.on('data', function (err) {
process.stdout.write('err: '+ err);
});
};
createSSH('joshua', '/node', 'id_rsa');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment