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()
}
fork icon2
star icon12
watch icon2

+ 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();
}
fork icon134
star icon1
watch icon1

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)
}
fork icon22
star icon457
watch icon17

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));
    });
},
fork icon9
star icon0
watch icon1

+ 3 other calls in file

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)
fork icon8
star icon0
watch icon1

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),
        });
    })
);
fork icon4
star icon6
watch icon4

+ 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()
fork icon1
star icon0
watch icon1

+ 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
  })
fork icon1
star icon0
watch icon7

+ 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,
fork icon0
star icon5
watch icon1

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');
fork icon0
star icon3
watch icon2

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);
});
fork icon0
star icon2
watch icon3

+ 5 other calls in file