Как подключиться по ssh к экземпляру EC2 через хост-бастион в nodejs

Я пробовал код ниже и использовал 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)

0 ответов

Другие вопросы по тегам