Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnhandledPromiseRejectionWarning: Error: invalid command ping www.google.com #445

Open
asdutoit opened this issue Sep 21, 2022 · 0 comments

Comments

@asdutoit
Copy link

asdutoit commented Sep 21, 2022

I am attempting to connect to one of my network switches via ssh and just run the command ping www.google.com but get the following error:

node index.js
Ping Completed
(node:56662) UnhandledPromiseRejectionWarning: Error: invalid command www.google.com.
...

My config:

ssh
  .connect({
    host: "172.35.0.2",
    username: "admin",
    port: 22,
    password,
    // debug: console.log,
    algorithms: {
      kex: [
        "diffie-hellman-group1-sha1",
        "ecdh-sha2-nistp256",
        "ecdh-sha2-nistp384",
        "ecdh-sha2-nistp521",
        "diffie-hellman-group-exchange-sha256",
        "diffie-hellman-group14-sha1",
      ],
      cipher: [
        "3des-cbc",
        "aes128-ctr",
        "aes192-ctr",
        "aes256-ctr",
        "aes128-gcm",
        "[email protected]",
        "aes256-gcm",
        "[email protected]",
      ],
      serverHostKey: [
        "ssh-rsa",
        "ecdsa-sha2-nistp256",
        "ecdsa-sha2-nistp384",
        "ecdsa-sha2-nistp521",
      ],
      hmac: ["hmac-sha2-256", "hmac-sha2-512", "hmac-sha1"],
    },
  })
  .then(() => {
    ssh
      .execCommand("ping www.google.com", { options: { pty: true } })
      .then((result) => {
        console.log("STDOUT: " + result.stdout);
        console.log("STDERR: " + result.stderr);
      });
  })
  .then(
    function () {
      console.log("Ping Completed");
    },
    function (error) {
      console.log("Something's wrong");
      console.log(error);
    }
  );

What am I doing wrong?

I am able to manually connect to the switch and run ping successfully:

olt-lab-01# ping www.google.com
Resolving www.google.com... 172.217.170.100
 sent  rcvd  rate    rtt     avg    mdev     max     min  reply from
    1     1  100      20      20       0      20      20  172.217.170.100
    2     2  100      95      29      19      95      20  172.217.170.100
    3     3  100      18      28      17      95      18  172.217.170.100
olt-lab-01# 
@asdutoit asdutoit changed the title UnhandledPromiseRejectionWarning: Error: invalid command ping www.google.co.za UnhandledPromiseRejectionWarning: Error: invalid command ping www.google.com Sep 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant