SSH-Keygen NPM软件包提供了未定义的公共和私钥

发布于 2025-01-17 15:40:28 字数 1024 浏览 2 评论 0原文

钥匙的输出对于私钥和公共密钥均未定义 [ssh-keygen] [1]

创建的密钥!

私钥:未定义
公钥:未定义

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
        })
    });
})
};

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
        })
    });
})
};

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦巷 2025-01-24 15:40:28

I have found this example,让您与自己的代码进行比较

  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);
      }
    });
  }

,请检查是否与该类型的功能获得了相同类型的错误消息。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文