如何解决如何通过Node.js中的堡垒主机SSH到EC2实例
我尝试了下面的代码,并使用了node-ssh-forward
NPM软件包。
const SSHConnection = require('node-ssh-forward').SSHConnection
var run = async () => {
const ssh = new SSHConnection({
username: 'Testuser',endHost: 'example.com',bastionHost: 'bastion01.aws.cloud',privateKey: 'C:/Users/user/.ssh/id_rsa'
})
await ssh.executeCommand('uptime')
}
run()
错误消息:
[2020-09-10T22:10:31.046Z] (node:14284) UnhandledPromiseRejectionWarning: Error:
Timed out while waiting for handshake at Timeout._onTimeout (C:\Program Files\nodejs\node_modules\npm\bin\NodeJS\n
ode_modules\ssh2\lib\client.js:695:19)
UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block,or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection,use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli
.html#cli_unhandled_rejections_mode). (rejection id: 3)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。