Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

202
Views
ssh-keygen npm package gives undefined public and private keys

Output for the keys is undefined for both private and public key [ssh-keygen][1]

Keys created!

private key: undefined
public key: undefined

async generateAndWriteSSHKeyv2() {
return new Promise((resolve, reject) => {

    let t = new Date().getTime();
    var location = path.join(process.cwd(), `contents/apps/SSHkeys/key_${t}`);
    var comment = 'test';
    var password = 'test';
    var format = 'PEM';
    keygen({
        location: location,
        comment: comment,
        password: password,
        read: true,
        destroy: false,
        format: format,
        size: 4096,
    }, (err, output) => {
        if (err) resolve(console.log('Something went wrong: ' + err));
        console.log('Keys created!');
        console.log('private key: ' + output.key);
        console.log('public key: ' + output.pubKey);
        resolve({
            location,
            comment,
            password,
            read: true,
            format,
            size: 4096,
            output
        })
    });
})
};
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I have found this example, for you to compare with your own code

  generateSshKeyFiles(name, next) {
    keygen({
      location: name,
      read: true,
      destroy: true,
    }, function(err, out) {
      if (err) {
        next(err);
      } else {
        let sshKeyFiles = [{'content': out.pubKey, 'fileName': name+'.pub'}, {'content': out.key, 'fileName': name}];
        next(null, sshKeyFiles);
      }
    });
  }

Check if you get the same kind of error message with that type of function.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!