How to use the ssh function from node-forge
Find comprehensive JavaScript node-forge.ssh code examples handpicked from public code repositorys.
35 36 37 38 39 40 41
const forgePublicKey = forge.pki.setRsaPublicKey( forgePrivateKey.n, forgePrivateKey.e ) return forge.ssh.publicKeyToOpenSSH(forgePublicKey).trim() }
2
12
2
+ 3 other calls in file
26 27 28 29 30 31 32
const privateKey = fs.readFileSync(privateKeyPath); const forgePrivateKey = forge.pki.privateKeyFromPem(privateKey); const forgePublicKey = forge.pki.setRsaPublicKey(forgePrivateKey.n, forgePrivateKey.e); return forge.ssh.publicKeyToOpenSSH(forgePublicKey).trim(); }
134
1
1
GitHub: maxogden/linux
205 206 207 208 209 210 211 212 213 214
} function saveNewKeypairSync () { var pair = keypair() var publicKey = forge.pki.publicKeyFromPem(pair.public) var ssh = forge.ssh.publicKeyToOpenSSH(publicKey, 'root@localhost') // todo would whoami + hostname be better? fs.writeFileSync(keyPath, pair.private, {mode: 384}) // 0600 fs.writeFileSync(keyPath + '.pub', ssh) }
22
457
17
306 307 308 309 310 311 312 313 314
forge.pki.rsa.generateKeyPair({bits: 2048, workers: 2/*e: 0x10001*/}, (err, keypair)=>{ if(err) { this.$notify({type: 'error', text: err}); return; } Vue.set(this.resource.config, 'ssh_public', forge.ssh.publicKeyToOpenSSH(keypair.publicKey));//, "pubkey comment"); Vue.set(this.resource.config, 'enc_ssh_private', forge.ssh.privateKeyToOpenSSH(keypair.privateKey)); }); },
9
0
1
+ 3 other calls in file
GitHub: 418sec/heroku-exec-util
139 140 141 142 143 144 145 146 147 148
function updateClientKey(context, heroku, configVars, callback) { return cli.action("Establishing credentials", {success: false}, co(function* () { var key = keypair(); var privkeypem = key.private; var publicKey = forge.pki.publicKeyFromPem(key.public); var pubkeypem = forge.ssh.publicKeyToOpenSSH(publicKey, ''); cli.hush(pubkeypem) var execUrl = _execUrl(context, configVars) var dyno = _dyno(context)
8
0
1
GitHub: hyperonecom/h1-cli
7 8 9 10 11 12 13 14 15 16
bits: 2048, workers: -1, }, (err, keypair) => { if (err) return reject(err); return resolve({ publicKey: forge.ssh.publicKeyToOpenSSH(keypair.publicKey, comment), privateKey: forge.ssh.privateKeyToOpenSSH(keypair.privateKey), }); }) );
4
6
4
+ 3 other calls in file
94 95 96 97 98 99 100 101 102 103
return this.useNetwork(id).getKeys() } const pair = keypair() const sshPublicKey = forge.pki.publicKeyFromPem(pair.public); const sshKey = forge.ssh.publicKeyToOpenSSH(sshPublicKey, 'web-automator@gantree.io'); fs.writeFileSync(publickey_path, sshKey) fs.writeFileSync(privatekey_path, pair.private, { mode: fs.constants.S_IRUSR }) return this.useNetwork(id).getKeys()
1
0
1
+ 5 other calls in file
17 18 19 20 21 22 23 24 25 26
}).unknown().required() module.exports.task = Promise.method((job) => { const pair = keypair() const publicKey = forge.pki.publicKeyFromPem(pair.public) const sshPublicKey = forge.ssh.publicKeyToOpenSSH(publicKey, 'support@runnable.com') return github.savePublicKey(job.githubAccessToken, { key: sshPublicKey, title: job.keyName })
1
0
7
+ 5 other calls in file
54 55 56 57 58 59 60 61 62 63
}, cb => { console.log(`[*] Saving public key file.`); const publicKey = Forge.pki.publicKeyFromPem(keyPair.public); sshKey = Forge.ssh.publicKeyToOpenSSH(publicKey, userName); FS.writeFile( Path.join(outputFolderName, 'id_rsa.pub'), sshKey,
0
5
1
27 28 29 30 31 32 33 34 35 36
const fs = require('fs'); const forge = require('node-forge'); const pki = forge.pki; const rsa = pki.rsa; const ssh = forge.ssh; const debug = require('debug').debug('sshui:dialog:credential-add'); const html = require('./credential-add.template.html');
0
3
2
26 27 28 29 30 31 32 33 34 35
} forge.rsa.generateKeyPair(opts, function(err, pair){ if (err) return cb(err); var keypair = { public: forge.ssh.publicKeyToOpenSSH(pair.publicKey), private: forge.ssh.privateKeyToOpenSSH(pair.privateKey), fingerprint: forge.ssh.getPublicKeyFingerprint(pair.publicKey, { encoding: 'hex' }) }; cb(null, keypair); });
0
2
3
+ 5 other calls in file
node-forge.pki is the most popular function in node-forge (10287 examples)