伙计们!当我尝试使用 remote-exec https://www.npmjs.com/package/remote-exec运行我的 cmd 时出现以下错误。
错误:生成公钥时无法解析私钥(预期顺序)
有谁知道为什么?谢谢!
我的代码:
controller.mySync = function(req, res) {
// remote-exec
var connection_options = {
port: 22,
username: 'user',
privateKey: require('fs').readFileSync('/home/host/.ssh/id_rsa'),
passphrase: 'mypws'
}
var hosts = [
'192.168.1.1'
];
var cmds = [
'ls -l',
'cat /etc/hosts'
];
rexec(hosts, cmds, connection_options, function(err, stdout, stderr){
if (err) {
console.log(err);
res.status(500).json(err);
} else {
console.log('Great Success!!');
res.status(200).json(stdout);
}
});
};