[英]ssh-keygen npm package gives undefined public and private keys
Output 对于私钥和公钥都未定义密钥 [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
})
});
})
};
我找到了这个例子,供您与自己的代码进行比较
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);
}
});
}
检查您是否收到与 function 类型相同的错误消息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.