[英]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] Output 对于私钥和公钥都未定义密钥 [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
})
});
})
};
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.检查您是否收到与 function 类型相同的错误消息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.